Update README.md
Browse files
README.md
CHANGED
@@ -42,10 +42,30 @@ model-index:
|
|
42 |
This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification.
|
43 |
This SetFit model uses [akhooli/sbert_ar_nli_500k_norm](https://huggingface.co/akhooli/sbert_ar_nli_500k_norm) as the Sentence Transformer embedding model.
|
44 |
A [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification.
|
45 |
-
Normalize the text before classifying as the model uses normalized text:
|
46 |
```python
|
|
|
|
|
47 |
from unicodedata import normalize
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
```
|
50 |
The rest of this card is auto-generated.
|
51 |
|
|
|
42 |
This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification.
|
43 |
This SetFit model uses [akhooli/sbert_ar_nli_500k_norm](https://huggingface.co/akhooli/sbert_ar_nli_500k_norm) as the Sentence Transformer embedding model.
|
44 |
A [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification.
|
45 |
+
Normalize the text before classifying as the model uses normalized text. Here's how to use the model:
|
46 |
```python
|
47 |
+
pip install setfit
|
48 |
+
from setfit import SetFitModel
|
49 |
from unicodedata import normalize
|
50 |
+
|
51 |
+
# Download model from Hub
|
52 |
+
model = SetFitModel.from_pretrained("akhooli/setfit_ar_sst2")
|
53 |
+
# Run inference
|
54 |
+
queries = [
|
55 |
+
"يغلي الماء عند 100 درجة مئوية",
|
56 |
+
"فعلا لقد أحببت ذلك الفيلم",
|
57 |
+
"🤮 اﻷناناس مع البيتزا؟ إنه غير محبذ",
|
58 |
+
"رأيت أناسا بائسين في الطريق",
|
59 |
+
"لم يعجبني المطعم رغم أن السعر مقبول",
|
60 |
+
"من باب جبر الخاطر هذه 3 نجوم لتقييم الخدمة",
|
61 |
+
"من باب جبر الخواطر، هذه نجمة واحدة لخدمة ﻻ تستحق"
|
62 |
+
]
|
63 |
+
queries_n = [normalize('NFKC', query) for query in queries]
|
64 |
+
preds = model.predict(queries_n)
|
65 |
+
print(preds)
|
66 |
+
# if you want to see the probabilities for each label
|
67 |
+
probas = model.predict_proba(queries_n)
|
68 |
+
print(probas)
|
69 |
```
|
70 |
The rest of this card is auto-generated.
|
71 |
|