Upload README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,139 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- summarization
|
4 |
+
- bart
|
5 |
+
|
6 |
+
language:
|
7 |
+
- gr
|
8 |
+
|
9 |
+
license: mit
|
10 |
+
|
11 |
+
pipeline_tag: "fill-mask"
|
12 |
+
---
|
13 |
+
# GreekBART: The First Pretrained Greek Sequence-to-Sequence Model
|
14 |
+
|
15 |
+
## Introduction
|
16 |
+
GreekBART is a Greek sequence to sequence pretrained model based on [BART](https://huggingface.co/facebook/bart-large).
|
17 |
+
GreekBART is pretrained by learning to reconstruct a corrupted input sentence. A corpus of 76.9GB of Greek raw text is used to carry out the pretraining.
|
18 |
+
Unlike already existing BERT-based Greek language model (GreekBERT), GreekBART is particularly well-suited for generative tasks (such as abstractive summarization), since not only its encoder but also its decoder is pretrained.
|
19 |
+
In addition to base GreekBART that is pretrained from scratch on the reconstruction, we finetune it as wll on three tasks: `greekbart-news24-abstract` that can generate an abstract given a Greek news article, `greekbart-news24-title` that can generate an title given a Greek news article, and `greekbart-sentiment-classification` finetuned on a binary sentinement classification task.
|
20 |
+
|
21 |
+
| Model | Architecture | #layers | #params |
|
22 |
+
| ------------- |:-------------:| :-----:|:-----:|
|
23 |
+
| [GreekBART](https://huggingface.co/dascim/greekbart) | BASE | 12 | 165M |
|
24 |
+
| [GreekBART Abstract](https://huggingface.co/dascim/greekbart-news27-abstract) | BASE | 12 | 165M |
|
25 |
+
| [GreekBART Title](https://huggingface.co/dascim/greekbart-news27-title) | BASE | 12 | 165M |
|
26 |
+
| [GreekBART Sentiment Classification](https://huggingface.co/dascim/greekbart-news27-title) | BASE | 12 | 165M |
|
27 |
+
|
28 |
+
<br>
|
29 |
+
|
30 |
+
paper: https://arxiv.org/pdf/2304.00869 \
|
31 |
+
github: https://github.com/iakovosevdaimon/GreekBART
|
32 |
+
|
33 |
+
|
34 |
+
## Usage
|
35 |
+
### Mask Prediction
|
36 |
+
```python
|
37 |
+
from transformers import pipeline
|
38 |
+
|
39 |
+
greekbart_fill_mask = pipeline("fill-mask", model="dascim/greekbart", tokenizer="dascim/greekbart")
|
40 |
+
results = greekbart_fill_mask("Η πρωτεύουσα της Ελλάδας είναι η <mask>")
|
41 |
+
|
42 |
+
results[0]
|
43 |
+
# {'score': 0.597200870513916, 'token': 7062, 'token_str': 'Αθήνα', 'sequence': 'Η πρωτεύουσα της Ελλάδας είναι η Αθήνα'},
|
44 |
+
|
45 |
+
```
|
46 |
+
### Abstract Generation
|
47 |
+
```python
|
48 |
+
text_sentence = 'Στην κατάθεση νοσηλεύτριας του Καραμανδάνειου Νοσοκομείου Πάτρας Παναγιώτας Τσεντούρου, η οποία εργαζόταν όταν εισήχθη στις 8 Απριλίου 2021 η Τζωρτζίνα, προχώρησε η διαδικασία ενώπιον του ΜΟΔ που δικάζει τη Ρούλα Πισπιρίγκου. Η νοσηλεύτρια κατέθεσε πως κατά την εισαγωγή του παιδιού "μου ανέφεραν πως είναι ένα παιδάκι που έχει χάσει τα αδελφάκια του και ότι είναι ιδιαίτερη περίπτωση" και εξιστόρησε τα γεγονότα της ημέρας εισαγωγής και της επομένης που η ίδια είχε βάρδια στην παιδιατρική κλινική.'
|
49 |
+
|
50 |
+
from transformers import (
|
51 |
+
AutoTokenizer,
|
52 |
+
AutoModelForSeq2SeqLM
|
53 |
+
)
|
54 |
+
|
55 |
+
tokenizer = AutoTokenizer.from_pretrained("dascim/greekbart-news24-abstract")
|
56 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("dascim/greekbart-news24-abstract")
|
57 |
+
|
58 |
+
input_ids = tokenizer.encode(text_sentence, add_special_tokens=True, return_tensors='pt')
|
59 |
+
|
60 |
+
model.eval()
|
61 |
+
predict = model.generate(input_ids, max_length=100)[0]
|
62 |
+
|
63 |
+
|
64 |
+
tokenizer.decode(predict, skip_special_tokens=True)
|
65 |
+
#'Η νοσηλεύτρια κατέθεσε πως κατά την εισαγωγή του παιδιού "μου ανέφεραν πως είναι ένα παιδάκι που έχει χάσει τα αδελφάκια του και ότι είναι ιδιαίτερη περίπτωση".'
|
66 |
+
```
|
67 |
+
|
68 |
+
### Title Generation
|
69 |
+
```python
|
70 |
+
text_sentence = 'Στην κατάθεση νοσηλεύτριας του Καραμανδάνειου Νοσοκομείου Πάτρας Παναγιώτας Τσεντούρου, η οποία εργαζόταν όταν εισήχθη στις 8 Απριλίου 2021 η Τζωρτζίνα, προχώρησε η διαδικασία ενώπιον του ΜΟΔ που δικάζει τη Ρούλα Πισπιρίγκου. Η νοσηλεύτρια κατέθεσε πως κατά την εισαγωγή του παιδιού "μου ανέφεραν πως είναι ένα παιδάκι που έχει χάσει τα αδελφάκια του και ότι είναι ιδιαίτερη περίπτωση" και εξιστόρησε τα γεγονότα της ημέρας εισαγωγής και της επομένης που η ίδια είχε βάρδια στην παιδιατρική κλινική.'
|
71 |
+
|
72 |
+
from transformers import (
|
73 |
+
AutoTokenizer,
|
74 |
+
AutoModelForSeq2SeqLM
|
75 |
+
)
|
76 |
+
|
77 |
+
tokenizer = AutoTokenizer.from_pretrained("dascim/greekbart-news24-title")
|
78 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("dascim/greekbart-news24-title")
|
79 |
+
|
80 |
+
input_ids = tokenizer.encode(text_sentence, add_special_tokens=True, return_tensors='pt')
|
81 |
+
|
82 |
+
model.eval()
|
83 |
+
predict = model.generate(input_ids, max_length=100)[0]
|
84 |
+
|
85 |
+
|
86 |
+
tokenizer.decode(predict, skip_special_tokens=True)
|
87 |
+
# 'Πάτρα: Κατάθεση νοσηλεύτριας για την εισαγωγή της Τζωρτζίνας στο νοσοκομείο'
|
88 |
+
```
|
89 |
+
|
90 |
+
### Sentiment Prediction
|
91 |
+
```python
|
92 |
+
text_sentence = "Ο ελληνικός πολιτισμός είναι ένας από τους πιο πλούσιους και αναγνωρισμένους πολιτισμούς."
|
93 |
+
|
94 |
+
from transformers import (
|
95 |
+
AutoTokenizer,
|
96 |
+
AutoModelForSequenceClassification
|
97 |
+
)
|
98 |
+
|
99 |
+
tokenizer = AutoTokenizer.from_pretrained("dascim/greekbart-sentiment-classification")
|
100 |
+
model = AutoModelForSequenceClassification.from_pretrained("dascim/greekbart-sentiment-classification")
|
101 |
+
|
102 |
+
input_ids = tokenizer.encode(text_sentence, add_special_tokens=True, return_tensors='pt')
|
103 |
+
|
104 |
+
model.eval()
|
105 |
+
predict = model(input_ids)[0]
|
106 |
+
|
107 |
+
print("negative" if predict.argmax(dim=-1).item()==1 else "positive")
|
108 |
+
# positive
|
109 |
+
```
|
110 |
+
|
111 |
+
## Authors
|
112 |
+
GreekBART was trained and evaluated ar École Polytechnique by Iakovos Evdaimon, Hadi Abdine, Christos Xypolopoulos, Stamatis Outsios, Michalis Vazirgiannis and Giorgos Stamou.
|
113 |
+
|
114 |
+
## Citation
|
115 |
+
If you use our work, please cite:
|
116 |
+
```bibtex
|
117 |
+
@inproceedings{evdaimon-etal-2024-greekbart,
|
118 |
+
title = "{G}reek{BART}: The First Pretrained {G}reek Sequence-to-Sequence Model",
|
119 |
+
author = "Evdaimon, Iakovos and
|
120 |
+
Abdine, Hadi and
|
121 |
+
Xypolopoulos, Christos and
|
122 |
+
Outsios, Stamatis and
|
123 |
+
Vazirgiannis, Michalis and
|
124 |
+
Stamou, Giorgos",
|
125 |
+
editor = "Calzolari, Nicoletta and
|
126 |
+
Kan, Min-Yen and
|
127 |
+
Hoste, Veronique and
|
128 |
+
Lenci, Alessandro and
|
129 |
+
Sakti, Sakriani and
|
130 |
+
Xue, Nianwen",
|
131 |
+
booktitle = "Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)",
|
132 |
+
month = may,
|
133 |
+
year = "2024",
|
134 |
+
address = "Torino, Italia",
|
135 |
+
publisher = "ELRA and ICCL",
|
136 |
+
url = "https://aclanthology.org/2024.lrec-main.700",
|
137 |
+
pages = "7949--7962",
|
138 |
+
}
|
139 |
+
```
|