Complete the code to load the RoBERTa tokenizer.
from transformers import [1] tokenizer = [1].from_pretrained('roberta-base')
The RobertaTokenizer is used to load the tokenizer for RoBERTa models.
Complete the code to load the DistilBERT model for sequence classification.
from transformers import [1] model = [1].from_pretrained('distilbert-base-uncased-finetuned-sst-2-english')
DistilBertForSequenceClassification loads the DistilBERT model fine-tuned for classification tasks.
Fix the error in the code to tokenize input text using RoBERTa tokenizer.
inputs = tokenizer([1], return_tensors='pt')
The tokenizer expects a string input, so passing a plain string like 'Hello, how are you?' is correct.
Fill both blanks to create a dictionary comprehension that maps tokens to their IDs using DistilBERT tokenizer.
token_ids = {token: [1] for token, [2] in tokenizer.get_vocab().items()}The items() returns (token, token_id) pairs, so the variable for the ID should be token_id.
Fill all three blanks to prepare inputs, run the model, and get logits using RoBERTa.
inputs = tokenizer([1], return_tensors=[2]) outputs = model([3]) logits = outputs.logits
We tokenize a string input, specify PyTorch tensors with 'pt', and pass inputs['input_ids'] to the model to get outputs.