Challenge - 5 Problems
Hugging Face Integration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Hugging Face tokenizer usage
What is the output of the following code snippet that uses a Hugging Face tokenizer to tokenize a sentence?
PyTorch
from transformers import AutoTokenizer tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased') inputs = tokenizer('Hello world!', return_tensors='pt') print(inputs['input_ids'].tolist())
Attempts:
2 left
💡 Hint
Remember that BERT tokenizers add special tokens at the start and end.
✗ Incorrect
The BERT tokenizer adds [CLS] token (101) at the start and [SEP] token (102) at the end. The tokens for 'Hello' and 'world' are 7592 and 2088, and '!' is 999.
❓ Model Choice
intermediate2:00remaining
Choosing the correct Hugging Face model for text classification
You want to perform sentiment analysis on movie reviews using Hugging Face. Which model is best suited for this task?
Attempts:
2 left
💡 Hint
Look for a model fine-tuned for sentiment analysis.
✗ Incorrect
Option A is a DistilBERT model fine-tuned on the SST-2 dataset for sentiment analysis, making it the best choice.
❓ Hyperparameter
advanced2:00remaining
Effect of batch size on Hugging Face model training
During fine-tuning a Hugging Face transformer model, what is the main effect of increasing the batch size?
Attempts:
2 left
💡 Hint
Think about computational resources and speed.
✗ Incorrect
Increasing batch size processes more samples at once, speeding up training but using more memory. It does not guarantee better accuracy or change learning rate automatically.
❓ Metrics
advanced2:00remaining
Correct metric for evaluating Hugging Face text generation
Which metric is most appropriate to evaluate the quality of text generated by a Hugging Face language model?
Attempts:
2 left
💡 Hint
Consider metrics used in machine translation and text generation.
✗ Incorrect
BLEU score measures how closely generated text matches reference text, commonly used for evaluating text generation quality.
🔧 Debug
expert2:00remaining
Identifying error in Hugging Face model loading code
What error will this code raise when trying to load a Hugging Face model and tokenizer?
PyTorch
from transformers import AutoModel, AutoTokenizer model = AutoModel.from_pretrained('bert-base-uncased') tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased') inputs = tokenizer('Test input', return_tensors='pt') outputs = model(inputs)
Attempts:
2 left
💡 Hint
Check how the model expects inputs.
✗ Incorrect
The model expects input tensors as keyword arguments like input_ids, but inputs is passed as a single positional argument causing a TypeError.