Commit
·
85290a9
1
Parent(s):
b5232d9
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,60 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- AyoubChLin/CNN_News_Articles_2011-2022
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
metrics:
|
| 8 |
+
- accuracy
|
| 9 |
+
pipeline_tag: zero-shot-classification
|
| 10 |
---
|
| 11 |
+
|
| 12 |
+
# DistilBERT for Zero Shot Classification
|
| 13 |
+
|
| 14 |
+
This repository contains a DistilBERT model trained for zero-shot classification on CNN articles. The model has been evaluated on CNN articles and achieved an accuracy of 0.956 and an F1 score of 0.955.
|
| 15 |
+
|
| 16 |
+
## Model Details
|
| 17 |
+
- Architecture: DistilBERT
|
| 18 |
+
- Training Data: CNN articles
|
| 19 |
+
- Accuracy: 0.956
|
| 20 |
+
- F1 Score: 0.955
|
| 21 |
+
|
| 22 |
+
## Usage
|
| 23 |
+
|
| 24 |
+
To use this model for zero-shot classification, you can follow the steps below:
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
1. Load the trained model:
|
| 29 |
+
```python
|
| 30 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 31 |
+
|
| 32 |
+
tokenizer = AutoTokenizer.from_pretrained("AyoubChLin/DistilBERT_ZeroShot")
|
| 33 |
+
|
| 34 |
+
model = AutoModelForSequenceClassification.from_pretrained("AyoubChLin/DistilBERT_ZeroShot")
|
| 35 |
+
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
4. Classify text using zero-shot classification:
|
| 39 |
+
```python
|
| 40 |
+
from transformers import pipeline
|
| 41 |
+
|
| 42 |
+
# Create a zero-shot classification pipeline
|
| 43 |
+
classifier = pipeline("zero-shot-classification", model=model, tokenizer=tokenizer)
|
| 44 |
+
|
| 45 |
+
# Classify a sentence
|
| 46 |
+
sentence = "The latest scientific breakthroughs in medicine"
|
| 47 |
+
candidate_labels = ["politics", "sports", "technology", "business"]
|
| 48 |
+
|
| 49 |
+
result = classifier(sentence, candidate_labels)
|
| 50 |
+
|
| 51 |
+
print(result)
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
The output will be a dictionary containing the classified label and the corresponding classification score.
|
| 55 |
+
|
| 56 |
+
## About the Author
|
| 57 |
+
|
| 58 |
+
This work was created by Ayoub Cherguelaine.
|
| 59 |
+
|
| 60 |
+
If you have any questions or suggestions regarding this repository or the trained model, feel free to reach out to Ayoub Cherguelaine.
|