Model Pipeline - Translation with Hugging Face
This pipeline translates text from one language to another using a Hugging Face transformer model. It takes input sentences, processes them, and outputs translated sentences.
Jump into concepts and practice - no test required
This pipeline translates text from one language to another using a Hugging Face transformer model. It takes input sentences, processes them, and outputs translated sentences.
Loss
5.0 |****
4.0 |***
3.0 |**
2.0 |*
1.0 |*
0.0 +----
1 2 3 4 5 Epochs| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 4.5 | 0.25 | Initial training with high loss and low accuracy |
| 2 | 3.2 | 0.45 | Loss decreased, accuracy improved |
| 3 | 2.1 | 0.65 | Model learning better translations |
| 4 | 1.3 | 0.80 | Good convergence, translations improving |
| 5 | 0.8 | 0.90 | Low loss and high accuracy, training stable |
from transformers import pipeline
translator = pipeline('translation_en_to_de')
result = translator('Hello, how are you?')
print(result[0]['translation_text'])from transformers import pipeline
translator = pipeline('translation_en_to_es')
result = translator('Good morning')
print(result['translation_text'])from transformers import pipeline
translator = pipeline('translation_en_to_fr')
sentences = ['Good night', 'See you later', 'Thank you']
# What is the best way to translate all sentences?