Challenge - 5 Problems
Translation Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of Hugging Face Translation Pipeline
What is the output of this code snippet that translates English to French using Hugging Face?
NLP
from transformers import pipeline translator = pipeline('translation_en_to_fr') result = translator('Hello, how are you?', max_length=40) print(result)
Attempts:
2 left
💡 Hint
Look for the most natural French translation of 'Hello, how are you?'.
✗ Incorrect
The Hugging Face translation pipeline returns a list of dictionaries with the key 'translation_text'. The most common and natural French translation for 'Hello, how are you?' is 'Bonjour, comment allez-vous ?'.
❓ Model Choice
intermediateChoosing the Correct Model for English to German Translation
Which Hugging Face model is best suited for translating English text to German?
Attempts:
2 left
💡 Hint
Look for a model specifically trained for translation between English and German.
✗ Incorrect
Helsinki-NLP/opus-mt-en-de is a MarianMT model trained specifically for English to German translation. The other models are not designed for translation tasks.
❓ Hyperparameter
advancedEffect of max_length in Translation Pipeline
What happens if you set max_length too low in the Hugging Face translation pipeline?
Attempts:
2 left
💡 Hint
Think about what max_length controls in text generation.
✗ Incorrect
max_length limits the number of tokens generated. If set too low, the output may be truncated and incomplete.
❓ Metrics
advancedEvaluating Translation Quality
Which metric is commonly used to evaluate the quality of machine translation outputs?
Attempts:
2 left
💡 Hint
This metric compares n-grams between the candidate and reference translations.
✗ Incorrect
BLEU score measures how many n-grams in the candidate translation match the reference translation, making it standard for translation evaluation.
🔧 Debug
expertDebugging Translation Pipeline Error
What error will this code raise and why?
from transformers import pipeline
translator = pipeline('translation_en_to_fr')
result = translator(['Hello', 'Goodbye'], max_length=40)
print(result)
NLP
from transformers import pipeline translator = pipeline('translation_en_to_fr') result = translator(['Hello', 'Goodbye'], max_length=40) print(result)
Attempts:
2 left
💡 Hint
Check if the translation pipeline supports batch input as a list.
✗ Incorrect
The Hugging Face translation pipeline supports batch input as a list of strings and returns a list of translations without error.
