ai-forever commited on
Commit
c724bd3
1 Parent(s): 90ad154

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +241 -0
README.md CHANGED
@@ -1,3 +1,244 @@
1
  ---
 
 
 
 
 
 
 
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - ru
4
+ - en
5
+ tags:
6
+ - spellchecking
7
+ - pytorch
8
+ - natural language generation
9
  license: mit
10
+ metrics:
11
+ - precision
12
+ - recall
13
+ - f1
14
+ library_name: transformers
15
+ model-index:
16
+ - name: sage-mt5-large
17
+ results:
18
+ - task:
19
+ type: text-generation
20
+ dataset:
21
+ type: spellcheck_benchmark
22
+ name: RUSpellRU
23
+ metrics:
24
+ - name: Precision
25
+ type: precision
26
+ value: 88.4
27
+ verified: false
28
+ - name: Recall
29
+ type: recall
30
+ value: 71.6
31
+ verified: false
32
+ - name: F1
33
+ type: f1
34
+ value: 79.1
35
+ verified: false
36
+ - task:
37
+ type: text-generation
38
+ dataset:
39
+ type: spellcheck_benchmark
40
+ name: MultidomainGold
41
+ metrics:
42
+ - name: Precision
43
+ type: precision
44
+ value: 65.3
45
+ verified: false
46
+ - name: Recall
47
+ type: recall
48
+ value: 62.7
49
+ verified: false
50
+ - name: F1
51
+ type: f1
52
+ value: 63.9
53
+ verified: false
54
+ - task:
55
+ type: text-generation
56
+ dataset:
57
+ type: spellcheck_benchmark
58
+ name: MedSpellchecker
59
+ metrics:
60
+ - name: Precision
61
+ type: precision
62
+ value: 77.7
63
+ verified: false
64
+ - name: Recall
65
+ type: recall
66
+ value: 77.5
67
+ verified: false
68
+ - name: F1
69
+ type: f1
70
+ value: 77.6
71
+ verified: false
72
+ - task:
73
+ type: text-generation
74
+ dataset:
75
+ type: spellcheck_benchmark
76
+ name: GitHubTypoCorpusRu
77
+ metrics:
78
+ - name: Precision
79
+ type: precision
80
+ value: 69.5
81
+ verified: false
82
+ - name: Recall
83
+ type: recall
84
+ value: 46.0
85
+ verified: false
86
+ - name: F1
87
+ type: f1
88
+ value: 55.3
89
+ verified: false
90
+ - task:
91
+ type: text-generation
92
+ dataset:
93
+ type: JFLEG
94
+ name: JFLEG
95
+ metrics:
96
+ - name: Precision
97
+ type: precision
98
+ value: 74.9
99
+ verified: false
100
+ - name: Recall
101
+ type: recall
102
+ value: 88.4
103
+ verified: false
104
+ - name: F1
105
+ type: f1
106
+ value: 81.1
107
+ verified: false
108
+ - task:
109
+ type: text-generation
110
+ dataset:
111
+ type: bea60k
112
+ name: BEA60K
113
+ metrics:
114
+ - name: Precision
115
+ type: precision
116
+ value: 64.7
117
+ verified: false
118
+ - name: Recall
119
+ type: recall
120
+ value: 83.8
121
+ verified: false
122
+ - name: F1
123
+ type: f1
124
+ value: 73.0
125
+ verified: false
126
  ---
127
+ # sage-mt5-large
128
+
129
+ ![banner](images/sage_banner.jpg)
130
+
131
+ ## Summary
132
+
133
+ The model corrects spelling errors and typos in both Russian and English languages by bringing all the words in the text to the norm of the language.
134
+ Corrector had been trained based on the model [FRED-T5-1.7B](https://huggingface.co/google/mt5-large) architecture.
135
+ An extensive dataset with “artificial” errors was taken as a training corpus: the corpus was assembled on the basis of the Russian-language Wikipedia and transcripts of Russian-language videos, then typos and spelling errors were automatically introduced into it using the library [SAGE](https://github.com/ai-forever/sage).
136
+
137
+ ## Public references
138
+ - [SAGE library announcement](https://youtu.be/yFfkV0Qjuu0), DataFest 2023
139
+ - [Paper about synthetic error generation methods](https://www.dialog-21.ru/media/5914/martynovnplusetal056.pdf), Dialogue 2023
140
+ - [SAGE EACL 2024 paper](https://aclanthology.org/2024.findings-eacl.10/)
141
+
142
+
143
+ ## Examples
144
+ | Input | Output |
145
+ | --- | --- |
146
+ | Перведи мне текст на аглиском: "Screw you kuys, I am goin hme (c). | Переведи мне текст на английском: "Screw you guys, I am going home" (c). |
147
+ | И не чсно прохожим в этот день непогожйи почему я веселый такйо | И мне ясно прохожим в этот день непогожий, почему я веселый такой |
148
+ | If you bought something goregous, you well be very happy. | If you bought something gorgeous, you will be very happy.|
149
+ | | |
150
+
151
+ ## Metrics
152
+ ### Quality
153
+ Below are automatic metrics for determining the correctness of the spell checkers.
154
+ We compare our solution with both open automatic spell checkers and the ChatGPT family of models on all six available datasets:
155
+ - **RUSpellRU**: texts collected from ([LiveJournal](https://www.livejournal.com/media)), with manually corrected typos and errors;
156
+ - **MultidomainGold**: examples from 7 text sources, including the open web, news, social media, reviews, subtitles, policy documents and literary works;
157
+ - **MedSpellChecker**: texts with errors from medical anamnesis;
158
+ - **GitHubTypoCorpusRu**: spelling errors and typos in commits from [GitHub](https://github.com);
159
+ - **BEA60K**: English spelling errors collected from several domains;
160
+ - **JFLEG**: 1601 sentences in English, which contain about 2 thousand spelling errors;
161
+
162
+ RUSpellRU, MultidomainGold, MedSpellChecker, GitHubTypoCorpusRu are datasets for the Russian spellchecking and BEA60K and JFLEG are those for the English language.
163
+
164
+ **RUSpellRU**
165
+ | Model | Precision | Recall | F1 |
166
+ | --- | --- | --- | --- |
167
+ | sage-mt5-large | 88.4 | 71.6 | 79.1 |
168
+ | sage-ai-service | 93.5 | 82.4 | 87.6 |
169
+ | gpt-3.5-turbo | 39.6 | 62.3 | 48.5 |
170
+ | gpt-4 | 69.5 | 81.0 | 74.8 |
171
+
172
+ **MultidomainGold**
173
+ | Model | Precision | Recall | F1 |
174
+ | --- | --- | --- | --- |
175
+ | sage-mt5-large | 65.3 | 62.7 | 63.9 |
176
+ | sage-ai-service | 70.9 | 68.8 | 69.9 |
177
+ | gpt-3.5-turbo | 17.8 | 56.1 | 27.0 |
178
+ | gpt-4 | 31.1 | 78.1 | 44.5 |
179
+
180
+ **MedSpellChecker**
181
+ | Model | Precision | Recall | F1 |
182
+ | --- | --- | --- | --- |
183
+ | sage-mt5-large | 77.7 | 77.5 | 77.6 |
184
+ | sage-ai-service | 73.4 | 76.2 | 74.9 |
185
+ | gpt-3.5-turbo | 15.1 | 53.6 | 23.5 |
186
+ | gpt-4 | 48.9 | 88.7 | 63.1 |
187
+
188
+
189
+ **GitHubTypoCorpusRu**
190
+ | Model | Precision | Recall | F1 |
191
+ | --- | --- | --- | --- |
192
+ | sage-mt5-large | 69.5 | 46.0 | 55.3 |
193
+ | sage-ai-service | 76.1 | 51.2 | 61.2 |
194
+ | gpt-3.5-turbo | 23.7 | 43.9 | 30.8 |
195
+ | gpt-4 | 34.7 | 60.5 | 44.1|
196
+
197
+
198
+ ## How to use
199
+ ```python
200
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
201
+
202
+ tokenizer = AutoTokenizer.from_pretrained("ai-forever/sage-mt5-large")
203
+ model = AutoModelForSeq2SeqLM.from_pretrained("ai-forever/sage-mt5-large")
204
+ model.to("cuda:0")
205
+
206
+ sentence = "Перведи мне текст на аглиском: \"Screw you kuys, I am goin hme (c)."
207
+ with torch.inference_mode():
208
+ encodings = tokenizer(sentence, max_length=None, padding="longest", truncation=False, return_tensors="pt")
209
+ for k, v in encodings.items():
210
+ encodings[k] = v.to("cuda:0")
211
+ res = model.generate(
212
+ **encodings,
213
+ use_cache=True,
214
+ max_length = encodings["input_ids"].size(1) * 1.5
215
+ )
216
+ res = res.cpu().tolist()
217
+ res = tokenizer.batch_decode(res, skip_special_tokens=True)
218
+
219
+ print(res)
220
+ # ["Переведи мне текст на английском: "Screw you guys, I am going home" (c)."]
221
+ ```
222
+
223
+ ## Limitations
224
+ - For the Russian language the model is intended to be fine-tuned for better performance.
225
+
226
+ ## Resources
227
+ - [SAGE library](https://github.com/ai-forever/sage), GitHub
228
+ - [sage-fredt5-large](https://huggingface.co/ai-forever/sage-fredt5-large), HuggingFace
229
+ - [sage-fredt5-distilled-95m](https://huggingface.co/ai-forever/sage-fredt5-distilled-95m), HuggingFace
230
+ - [sage-m2m100-1.2B](https://huggingface.co/ai-forever/sage-m2m100-1.2B), HuggingFace
231
+ - [sage-mt5-large](https://huggingface.co/ai-forever/sage-mt5-large), HuggingFace
232
+
233
+ ## License
234
+ Model [mT5-large](https://huggingface.co/google/mt5-large), on the basis of which our solution is made, and its source code are supplied under the Apache-2.0 license.
235
+ Our solution comes with MIT license.
236
+
237
+ ## Specifications
238
+ - File size: 5 Gb;
239
+ - Framework: pytorch
240
+ - Version: v1.0
241
+ - Developer: SberDevices, AGI NLP
242
+
243
+ ## Contacts
244
+ nikita.martynov.98@list.ru