abhik1505040 commited on
Commit
e01d7dd
1 Parent(s): 91041ad

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +187 -0
README.md ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - summarization
4
+ - mT5
5
+ language:
6
+ - am
7
+ - ar
8
+ - az
9
+ - bn
10
+ - my
11
+ - zh
12
+ - en
13
+ - fr
14
+ - gu
15
+ - ha
16
+ - hi
17
+ - ig
18
+ - id
19
+ - ja
20
+ - rn
21
+ - ko
22
+ - ky
23
+ - mr
24
+ - ne
25
+ - om
26
+ - ps
27
+ - fa
28
+ - pcm
29
+ - pt
30
+ - pa
31
+ - ru
32
+ - gd
33
+ - sr
34
+ - si
35
+ - so
36
+ - es
37
+ - sw
38
+ - ta
39
+ - te
40
+ - th
41
+ - ti
42
+ - tr
43
+ - uk
44
+ - ur
45
+ - uz
46
+ - vi
47
+ - cy
48
+ - yo
49
+ licenses:
50
+ - cc-by-nc-sa-4.0
51
+ widget:
52
+ - text: >-
53
+ Videos that say approved vaccines are dangerous and cause autism, cancer or
54
+ infertility are among those that will be taken down, the company said. The
55
+ policy includes the termination of accounts of anti-vaccine influencers.
56
+ Tech giants have been criticised for not doing more to counter false health
57
+ information on their sites. In July, US President Joe Biden said social
58
+ media platforms were largely responsible for people's scepticism in getting
59
+ vaccinated by spreading misinformation, and appealed for them to address the
60
+ issue. YouTube, which is owned by Google, said 130,000 videos were removed
61
+ from its platform since last year, when it implemented a ban on content
62
+ spreading misinformation about Covid vaccines. In a blog post, the company
63
+ said it had seen false claims about Covid jabs "spill over into
64
+ misinformation about vaccines in general". The new policy covers
65
+ long-approved vaccines, such as those against measles or hepatitis B.
66
+ "We're expanding our medical misinformation policies on YouTube with new
67
+ guidelines on currently administered vaccines that are approved and
68
+ confirmed to be safe and effective by local health authorities and the WHO,"
69
+ the post said, referring to the World Health Organization.
70
+ datasets:
71
+ - csebuetnlp/CrossSum
72
+ ---
73
+
74
+ # mT5-m2m-CrossSum-enhanced
75
+
76
+ This repository contains the many-to-many (m2m) mT5 checkpoint finetuned on all cross-lingual pairs of the [CrossSum](https://huggingface.co/datasets/csebuetnlp/CrossSum) dataset. This model tries to **summarize text written in any language in the provided target language.** For finetuning details and scripts, see the [paper](https://arxiv.org/abs/2112.08804) and the [official repository](https://github.com/csebuetnlp/CrossSum).
77
+
78
+
79
+ ## Using this model in `transformers` (tested on 4.11.0.dev0)
80
+
81
+ ```python
82
+ import re
83
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
84
+
85
+ WHITESPACE_HANDLER = lambda k: re.sub('\s+', ' ', re.sub('\n+', ' ', k.strip()))
86
+
87
+ article_text = """Videos that say approved vaccines are dangerous and cause autism, cancer or infertility are among those that will be taken down, the company said. The policy includes the termination of accounts of anti-vaccine influencers. Tech giants have been criticised for not doing more to counter false health information on their sites. In July, US President Joe Biden said social media platforms were largely responsible for people's scepticism in getting vaccinated by spreading misinformation, and appealed for them to address the issue. YouTube, which is owned by Google, said 130,000 videos were removed from its platform since last year, when it implemented a ban on content spreading misinformation about Covid vaccines. In a blog post, the company said it had seen false claims about Covid jabs "spill over into misinformation about vaccines in general". The new policy covers long-approved vaccines, such as those against measles or hepatitis B. "We're expanding our medical misinformation policies on YouTube with new guidelines on currently administered vaccines that are approved and confirmed to be safe and effective by local health authorities and the WHO," the post said, referring to the World Health Organization."""
88
+
89
+ model_name = "csebuetnlp/mT5_m2m_crossSum_enhanced"
90
+ tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False)
91
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
92
+
93
+ get_lang_id = lambda lang: tokenizer._convert_token_to_id(
94
+ model.config.task_specific_params["langid_map"][lang][1]
95
+ )
96
+
97
+ target_lang = "english" # for a list of available language names see below
98
+
99
+ input_ids = tokenizer(
100
+ [WHITESPACE_HANDLER(article_text)],
101
+ return_tensors="pt",
102
+ padding="max_length",
103
+ truncation=True,
104
+ max_length=512
105
+ )["input_ids"]
106
+
107
+ output_ids = model.generate(
108
+ input_ids=input_ids,
109
+ decoder_start_token_id=get_lang_id(target_lang),
110
+ max_length=84,
111
+ no_repeat_ngram_size=2,
112
+ num_beams=4,
113
+ )[0]
114
+
115
+ summary = tokenizer.decode(
116
+ output_ids,
117
+ skip_special_tokens=True,
118
+ clean_up_tokenization_spaces=False
119
+ )
120
+
121
+ print(summary)
122
+ ```
123
+
124
+ ### Available target language names
125
+ - `amharic`
126
+ - `arabic`
127
+ - `azerbaijani`
128
+ - `bengali`
129
+ - `burmese`
130
+ - `chinese_simplified`
131
+ - `chinese_traditional`
132
+ - `english`
133
+ - `french`
134
+ - `gujarati`
135
+ - `hausa`
136
+ - `hindi`
137
+ - `igbo`
138
+ - `indonesian`
139
+ - `japanese`
140
+ - `kirundi`
141
+ - `korean`
142
+ - `kyrgyz`
143
+ - `marathi`
144
+ - `nepali`
145
+ - `oromo`
146
+ - `pashto`
147
+ - `persian`
148
+ - `pidgin`
149
+ - `portuguese`
150
+ - `punjabi`
151
+ - `russian`
152
+ - `scottish_gaelic`
153
+ - `serbian_cyrillic`
154
+ - `serbian_latin`
155
+ - `sinhala`
156
+ - `somali`
157
+ - `spanish`
158
+ - `swahili`
159
+ - `tamil`
160
+ - `telugu`
161
+ - `thai`
162
+ - `tigrinya`
163
+ - `turkish`
164
+ - `ukrainian`
165
+ - `urdu`
166
+ - `uzbek`
167
+ - `vietnamese`
168
+ - `welsh`
169
+ - `yoruba`
170
+
171
+
172
+
173
+ ## Citation
174
+
175
+ If you use this model, please cite the following paper:
176
+ ```
177
+ @article{hasan2021crosssum,
178
+ author = {Tahmid Hasan and Abhik Bhattacharjee and Wasi Uddin Ahmad and Yuan-Fang Li and Yong-bin Kang and Rifat Shahriyar},
179
+ title = {CrossSum: Beyond English-Centric Cross-Lingual Abstractive Text Summarization for 1500+ Language Pairs},
180
+ journal = {CoRR},
181
+ volume = {abs/2112.08804},
182
+ year = {2021},
183
+ url = {https://arxiv.org/abs/2112.08804},
184
+ eprinttype = {arXiv},
185
+ eprint = {2112.08804}
186
+ }
187
+ ```