Views
No views yet
This is an RKNN-compatible version of the distilbert/distilbert-base-uncased-finetuned-sst-2-english model. It has been optimized for Rockchip NPUs using the rk-transformers library.
| Model File | Optimization Level | Quantization | File Size |
|---|---|---|---|
| model.rknn | 0 | float16 | 131.5 MB |
| model_b1_s256.rknn | 0 | float16 | 129.9 MB |
| model_b4_s256.rknn | 0 | float16 | 135.9 MB |
| model_b4_s512.rknn | 0 | float16 | 141.3 MB |
| rknn/model_o1.rknn | 1 | float16 | 131.5 MB |
| rknn/model_o2.rknn | 2 | float16 | 131.5 MB |
| rknn/model_o3.rknn | 3 | float16 | 131.5 MB |
| rknn/model_w8a8.rknn | 0 | w8a8 | 67.2 MB |
rk-transformers with inference dependencies to use this model:pip install rk-transformers[inference]1from rktransformers import RKModelForSequenceClassification
2from transformers import AutoTokenizer
3
4tokenizer = AutoTokenizer.from_pretrained("rk-transformers/distilbert-base-uncased-finetuned-sst-2-english")
5model = RKModelForSequenceClassification.from_pretrained(
6 "rk-transformers/distilbert-base-uncased-finetuned-sst-2-english",
7 platform="rk3588",
8 core_mask="auto",
9)
10
11inputs = tokenizer("Hello, my dog is cute", return_tensors="np")
12outputs = model(**inputs)
13logits = outputs.logits
14print(logits.shape)
15
16# Load specific optimized/quantized model file
17model = RKModelForSequenceClassification.from_pretrained(
18 "rk-transformers/distilbert-base-uncased-finetuned-sst-2-english",
19 platform="rk3588",
20 file_name="rknn/model_w8a8.rknn"
21)1import torch
2from transformers import DistilBertTokenizer, DistilBertForSequenceClassification
3
4tokenizer = DistilBertTokenizer.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english")
5model = DistilBertForSequenceClassification.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english")
6
7inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
8with torch.no_grad():
9 logits = model(**inputs).logits
10
11predicted_class_id = logits.argmax().item()
12model.config.id2label[predicted_class_id]
13This film was filmed in COUNTRY, this binary classification model will give radically different probabilities for the positive label depending on the country (0.89 if the country is France, but 0.08 if the country is Afghanistan) when nothing in the input indicates such a strong semantic shift. In this colab, Aurélien Géron made an interesting map plotting these probabilities for each country.