Instructions to use zeroshot/sst2-distilbert-sparse with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zeroshot/sst2-distilbert-sparse with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="zeroshot/sst2-distilbert-sparse")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("zeroshot/sst2-distilbert-sparse") model = AutoModelForSequenceClassification.from_pretrained("zeroshot/sst2-distilbert-sparse") - Notebooks
- Google Colab
- Kaggle
# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("zeroshot/sst2-distilbert-sparse")
model = AutoModelForSequenceClassification.from_pretrained("zeroshot/sst2-distilbert-sparse")Quick Links
DISTILBERT RUNNING ON DEEPSPARSE GOES BRHMMMMMMMM. πππ
This model is π
ββββββββ βββββββ ββββββ βββββββ ββββββββ ββββββββ
ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ
ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββ
ββββββββ βββββββ ββββββββ ββββββββ βββββββββ βββββ
ββββββββ βββ βββ βββ βββ ββ βββββββββ ββββββββ
ββββββββ βββ βββ βββ βββ ββ βββββββββ ββββββββ
LOOKS LIKE THIS π
Inference endpoints, outside of outliers (4ms) is avg. latency on 2 vCPUs:
Handler for access to inference endpoints
class EndpointHandler:
def __init__(self, path=""):
self.pipeline = Pipeline.create(task="text-classification", model_path=path)
def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:
"""
Args:
data (:obj:): prediction input text
"""
inputs = data.pop("inputs", data)
start = perf_counter()
prediction = self.pipeline(inputs)
end = perf_counter()
latency = end - start
return {
"labels": prediction.labels,
"scores": prediction.scores,
"latency (secs.)": latency
}
Μ·ΜΝ Μ΅ΝΜ³RΜΆΝΜiΜΈΝΜcΜ΄ΜΜ»kΜΈΜΝyΜ·ΝΜ³ ΜΈΜΜͺ Μ·ΝΝ
- Downloads last month
- 11



# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="zeroshot/sst2-distilbert-sparse")