Instructions to use Goud/AraBERT-summarization-goud with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Goud/AraBERT-summarization-goud with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "summarization" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("summarization", model="Goud/AraBERT-summarization-goud")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("Goud/AraBERT-summarization-goud") model = AutoModelForSeq2SeqLM.from_pretrained("Goud/AraBERT-summarization-goud") - Notebooks
- Google Colab
- Kaggle
Upload app.py
#2
by abdulhamed - opened
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import EncoderDecoderModel, BertTokenizer
|
| 3 |
+
|
| 4 |
+
model = EncoderDecoderModel.from_pretrained("abdulhamed/AraBert-summarize")
|
| 5 |
+
tokenizer = BertTokenizer.from_pretrained("abdulhamed/AraBert-summarize")
|
| 6 |
+
|
| 7 |
+
def summarize_article(article):
|
| 8 |
+
input_ids = tokenizer(article, return_tensors="pt", truncation=True, padding=True).input_ids
|
| 9 |
+
generated = model.generate(input_ids)[0]
|
| 10 |
+
summary = tokenizer.decode(generated, skip_special_tokens=True)
|
| 11 |
+
return summary
|
| 12 |
+
|
| 13 |
+
iface = gr.Interface(
|
| 14 |
+
fn=summarize_article,
|
| 15 |
+
inputs=gr.Textbox(lines=10, label="Article"),
|
| 16 |
+
outputs=gr.Textbox(label="Summary"),
|
| 17 |
+
title="AraBERT Summarization"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
iface.launch()
|