Challenge - 5 Problems
Translation Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
β Predict Output
intermediate2:00remaining
Output 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
intermediate1:30remaining
Choosing 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
advanced1:30remaining
Effect 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
advanced1:30remaining
Evaluating 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
expert2:30remaining
Debugging 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.