nyu-mll/glue
Viewer • Updated • 1.49M • 481k • 501
How to use echarlaix/distilbert-base-uncased-finetuned-sst-2-english-int8-dynamic with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="echarlaix/distilbert-base-uncased-finetuned-sst-2-english-int8-dynamic") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("echarlaix/distilbert-base-uncased-finetuned-sst-2-english-int8-dynamic")
model = AutoModelForSequenceClassification.from_pretrained("echarlaix/distilbert-base-uncased-finetuned-sst-2-english-int8-dynamic")Model Description: This model is a DistilBERT fine-tuned on SST-2 dynamically quantized with optimum-intel through the usage of Intel® Neural Compressor.
This requires to install Optimum :
pip install optimum[neural-compressor]
To load the quantized model and run inference using the Transformers pipelines, you can do as follows:
from transformers import AutoTokenizer, pipeline
from optimum.intel import INCModelForSequenceClassification
model_id = "echarlaix/distilbert-base-uncased-finetuned-sst-2-english-int8-dynamic"
model = INCModelForSequenceClassification.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
cls_pipe = pipeline("text-classification", model=model, tokenizer=tokenizer)
text = "He's a dreadful magician."
outputs = cls_pipe(text)