File size: 667 Bytes
a5f918f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | from transformers import pipeline
import numpy
# distilbert tasks
# fill-mask
# feature extraction
# have to use more specific models/other models for other tasks
#for mask gen
unmasker = pipeline('fill-mask', model='distilbert-base-uncased', device=0)
results = unmasker("I [MASK] today.", top_k=10)
for prediction in results:
print(f"Score: {prediction['score']:.4f} | Prediction: {prediction['sequence']}")
#for feature extraction
extractor = pipeline('feature-extraction', model='distilbert-base-uncased', device=0)
results = extractor("Obama")
#idk what this really does
features = numpy.array(results)
print(f"Shape: {features.shape}") |