File size: 397 Bytes
a5f918f | 1 2 3 4 5 6 7 8 9 10 | from transformers import pipeline
# roberta tasks
# fill-mask
# feature extraction
# have to use more specific models/other models for other tasks
# for mask gen
unmasker = pipeline('fill-mask', model='roberta-base', device=0)
results = unmasker("Obama is <mask>.", top_k=10)
for prediction in results:
print(f"Score: {prediction['score']:.4f} | Prediction: {prediction['sequence']}") |