Text Classification
Transformers
PyTorch
Arabic
t5
text2text-generation
Classification
ArabicT5
Text Classification
Instructions to use Hezam/ArabicT5_Classification with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Hezam/ArabicT5_Classification with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Hezam/ArabicT5_Classification")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("Hezam/ArabicT5_Classification") model = AutoModelForSeq2SeqLM.from_pretrained("Hezam/ArabicT5_Classification", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -56,7 +56,26 @@ widget:
|
|
| 56 |
|
| 57 |
# # Example usage
|
| 58 |
```python
|
|
|
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
```
|
|
|
|
| 56 |
|
| 57 |
# # Example usage
|
| 58 |
```python
|
| 59 |
+
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
| 60 |
|
| 61 |
+
model_name="Hezam/ArabicT5_Classification"
|
| 62 |
+
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
| 63 |
+
tokenizer = T5Tokenizer.from_pretrained(model_name)
|
| 64 |
+
|
| 65 |
+
text = "الزين فيك القناه الاولي المغربيه الزين فيك القناه الاولي المغربيه اخبارنا المغربيه متابعه تفاجا زوار موقع القناه الاولي المغربي"
|
| 66 |
+
tokens=tokenizer(text, max_length=200,
|
| 67 |
+
truncation=True,
|
| 68 |
+
padding="max_length",
|
| 69 |
+
return_tensors="pt"
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
output= model.generate(tokens['input_ids'],
|
| 73 |
+
max_length=3,
|
| 74 |
+
length_penalty=10)
|
| 75 |
|
| 76 |
+
output = [tokenizer.decode(ids, skip_special_tokens=True,clean_up_tokenization_spaces=True)for ids in output]
|
| 77 |
+
output
|
| 78 |
+
|
| 79 |
+
```bash
|
| 80 |
+
['5']
|
| 81 |
```
|