from transformers import DistilBertTokenizer, DistilBertModel | |
import torch | |
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-cased-distilled-squad') | |
model = DistilBertModel.from_pretrained('distilbert-base-cased-distilled-squad') | |
question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet." | |
inputs = tokenizer(question, text, return_tensors="pt") | |
with torch.no_grad(): | |
outputs = model(**inputs) | |
print(outputs) |