ai-forever commited on
Commit
c788f82
1 Parent(s): 7b16acf

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +204 -0
README.md CHANGED
@@ -1,3 +1,207 @@
1
  ---
 
 
 
 
 
 
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - ru
4
+ tags:
5
+ - spellchecking
6
+ - pytorch
7
+ - natural language generation
8
  license: mit
9
+ metrics:
10
+ - precision
11
+ - recall
12
+ - f1
13
+ library_name: transformers
14
+ model-index:
15
+ - name: sage-fredt5-large
16
+ results:
17
+ - task:
18
+ type: text-generation
19
+ dataset:
20
+ type: spellcheck_benchmark
21
+ name: RUSpellRU (spell&punct)
22
+ metrics:
23
+ - name: F1 (spell)
24
+ type: f1_spell
25
+ value: 62.2
26
+ verified: false
27
+ - name: F1 (punct)
28
+ type: f1_punct
29
+ value: 60.2
30
+ verified: false
31
+ - name: F1 (case)
32
+ type: f1_case
33
+ value: 78.1
34
+ verified: false
35
+ - task:
36
+ type: text-generation
37
+ dataset:
38
+ type: spellcheck_benchmark
39
+ name: MultidomainGold (spell&punct)
40
+ metrics:
41
+ - name: F1 (spell)
42
+ type: f1_spell
43
+ value: 46.3
44
+ verified: false
45
+ - name: F1 (punct)
46
+ type: f1_punct
47
+ value: 21.6
48
+ verified: false
49
+ - name: F1 (case)
50
+ type: f1_case
51
+ value: 34.0
52
+ verified: false
53
+ - task:
54
+ type: text-generation
55
+ dataset:
56
+ type: spellcheck_benchmark
57
+ name: MedSpellchecker (spell&punct)
58
+ metrics:
59
+ - name: F1 (spell)
60
+ type: f1_spell
61
+ value: 42.7
62
+ verified: false
63
+ - name: F1 (punct)
64
+ type: f1_punct
65
+ value: 15.7
66
+ verified: false
67
+ - name: F1 (case)
68
+ type: f1_case
69
+ value: 41.9
70
+ verified: false
71
+ - task:
72
+ type: text-generation
73
+ dataset:
74
+ type: spellcheck_benchmark
75
+ name: GitHubTypoCorpusRu (spell&punct)
76
+ metrics:
77
+ - name: F1 (spell)
78
+ type: f1_spell
79
+ value: 46.3
80
+ verified: false
81
+ - name: F1 (punct)
82
+ type: f1_punct
83
+ value: 20.2
84
+ verified: false
85
+ - name: F1 (case)
86
+ type: f1_case
87
+ value: 12.6
88
+ verified: false
89
  ---
90
+ # sage-fredt5-large
91
+
92
+ ![banner](images/sage_banner.jpg)
93
+
94
+ ## Summary
95
+
96
+ The model corrects spelling and punctuation errors and typos by bringing all the words in the text to the norm of the Russian language.
97
+ Corrector had been trained based on the model [FRED-T5-large](https://huggingface.co/ai-forever/FRED-T5-large).
98
+ 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).
99
+
100
+ ## Public references
101
+ - [SAGE library announcement](https://youtu.be/yFfkV0Qjuu0), DataFest 2023
102
+ - [Paper about synthetic error generation methods](https://www.dialog-21.ru/media/5914/martynovnplusetal056.pdf), Dialogue 2023
103
+ - [SAGE EACL 2024 paper](https://aclanthology.org/2024.findings-eacl.10/)
104
+
105
+
106
+ ## Examples
107
+ | Input | Output |
108
+ | --- | --- |
109
+ | И не чсно прохожим в этот день непогожйи почему я веселый такйо | И не ясно прохожим в этот день непогожий, почему я веселый такой. |
110
+ | Каждй день воттак делой, и спена балеть нибудет. А вотак каждый день ниделай | Каждый день вот так делай и спина болеть не будет. А вот так каждый день не делай. |
111
+ | Основая цель мероприятия практическая отработка навыков по оказанию помощи гражданам, попавшим в ДТП а также повышение и совершенствование уровня профессиональной подготовки сотрудников МЧС при проведении аварийно-спасательных работ по ликвидации последствий дорожно-транспортных проишествий сокращение временных показателей реагирования. | Основная цель мероприятия — практическая отработка навыков по оказанию помощи гражданам, попавшим в ДТП, а также повышение и совершенствование уровня профессиональной подготовки сотрудников МЧС при проведении аварийно-спасательных работ по ликвидации последствий дорожно-транспортных происшествий, сокращение временных показателей реагирования |
112
+ | | |
113
+
114
+ ## Metrics
115
+ ### Quality
116
+ Below are automatic metrics for determining the correctness of the spell checkers.
117
+ We compare our solution with both open automatic spell checkers and the ChatGPT family of models on all four available datasets:
118
+ - **RUSpellRU**: texts collected from ([LiveJournal](https://www.livejournal.com/media)), with manually corrected typos and errors;
119
+ - **MultidomainGold**: examples from 7 text sources, including the open web, news, social media, reviews, subtitles, policy documents and literary works;
120
+ - **MedSpellChecker**: texts with errors from medical anamnesis;
121
+ - **GitHubTypoCorpusRu**: spelling errors and typos in commits from [GitHub](https://github.com);
122
+
123
+ **RUSpellRU**
124
+ | Model | Pr. (spell) | Rec. (spell) | F1 (spell) | Pr. (punc) | Rec. (punc) | F1 (punc) | Pr. (case) | Rec. (case) | F1 (case) |
125
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
126
+ | sage-fredt5-large | 57.3 | 68.0 | 62.2 | 86.7 | 46.1 | 60.2 | 92.1 | 67.8 | 78.1 |
127
+ | sage-fredt5-large (ft) | 88.4 | 80.9 | 84.5 | 88.2 | 85.3 | 86.8 | 95.5 | 94.0 | 94.7 |
128
+ | sage-ai-service | 90.3 | 86.3 | 88.2 | 90.3 | 86.6 | 88.4 | 95.2 | 95.9 | 95.6 |
129
+ | gpt-3.5-turbo | 33.6 | 58.5 | 42.7 | 85.9 | 64.6 | 73.7 | 84.9 | 73.9 | 79.0 |
130
+ | gpt-4 | 54.9 | 76.7 | 64.0 | 84.0 | 82.3 | 83.2 | 91.5 | 90.2 | 90.9 |
131
+
132
+
133
+ **MultidomainGold**
134
+ | Model | Pr. (spell) | Rec. (spell) | F1 (spell) | Pr. (punc) | Rec. (punc) | F1 (punc) | Pr. (case) | Rec. (case) | F1 (case) |
135
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
136
+ | sage-fredt5-large | 43.4 | 49.7 | 46.3 | 21.8 | 21.3 | 21.6 | 58.8 | 23.9 | 34.0 |
137
+ | sage-fredt5-large (ft) | 80.3 | 75.1 | 77.6 | 69.0 | 66.5 | 67.7 | 78.6 | 80.0 | 79.3 |
138
+ | sage-ai-service | 81.6 | 77.7 | 79.6 | 70.2 | 67.5 | 68.8 | 80.5 | 80.5 | 80.5 |
139
+ | gpt-3.5-turbo | 18.8 | 48.1 | 27.1 | 42.0 | 31.8 | 36.2 | 47.1 | 51.3 | 49.1 |
140
+ | gpt-4 | 25.4 | 68.0 | 37.0 | 57.8 | 54.3 | 56.0 | 54.0 | 67.5 | 60.0 |
141
+
142
+
143
+ **MedSpellChecker**
144
+ | Model | Pr. (spell) | Rec. (spell) | F1 (spell) | Pr. (punc) | Rec. (punc) | F1 (punc) | Pr. (case) | Rec. (case) | F1 (case) |
145
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
146
+ | sage-fredt5-large | 35.2 | 54.5 | 42.8 | 19.2 | 13.2 | 15.7 | 48.7 | 36.8 | 41.9 |
147
+ | sage-fredt5-large (ft) | 72.5 | 72.2 | 72.3 | 74.6 | 66.4 | 70.3 | 79.3 | 85.1 | 82.1 |
148
+ | sage-ai-service | 71.3 | 73.5 | 72.4 | 75.1 | 69.2 | 72.0 | 80.9 | 72.8 | 76.6|
149
+ | gpt-3.5-turbo | 14.7 | 45.9 | 22.3 | 69.9 | 52.3 | 59.8 | 26.4 | 41.8 | 32.3 |
150
+ | gpt-4 | 37.8 | 72.3 | 49.6 | 81.4 | 64.3 | 71.9 | 73.0 | 62.1 | 67.1 |
151
+
152
+
153
+ **GitHubTypoCorpusRu**
154
+ | Model | Pr. (spell) | Rec. (spell) | F1 (spell) | Pr. (punc) | Rec. (punc) | F1 (punc) | Pr. (case) | Rec. (case) | F1 (case) |
155
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
156
+ | sage-fredt5-large | 46.0 | 46.6 | 46.3 | 22.7 | 18.3 | 20.2 | 12.0 | 13.2 | 12.6 |
157
+ | sage-fredt5-large (ft) | 67.5 | 53.2 | 59.5 | 48.5 | 38.0 | 42.6 | 37.3 | 50.0 | 42.7 |
158
+ | sage-ai-service | 70.8 | 56.3 | 62.7 | 48.9 | 35.8 | 41.4 | 32.9 | 45.3 | 38.1|
159
+ | gpt-3.5-turbo | 23.7 | 38.7 | 29.4 | 37.6 | 23.3 | 28.7 | 19.6 | 35.9 | 25.3 |
160
+ | gpt-4 | 27.0 | 52.8 | 35.7 | 45.9 | 32.6 | 38.2 | 25.7 | 36.8 | 30.2 |
161
+
162
+ ## How to use
163
+ ```python
164
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
165
+ tokenizer = AutoTokenizer.from_pretrained("ai-forever/sage-fredt5-large")
166
+ model = AutoModelForSeq2SeqLM.from_pretrained("ai-forever/sage-fredt5-large")
167
+ model.to("cuda:0")
168
+ sentence = "И не чсно прохожим в этот день непогожйи почему я веселый такйо"
169
+ text = "<LM>" + sentence
170
+ with torch.inference_mode():
171
+ encodings = tokenizer(text, max_length=None, padding="longest", truncation=False, return_tensors="pt")
172
+ for k, v in encodings.items():
173
+ encodings[k] = v.to("cuda:0")
174
+ res = model.generate(
175
+ **encodings,
176
+ use_cache=True,
177
+ max_length = encodings["input_ids"].size(1) * 1.5
178
+ )
179
+ res = res.cpu().tolist()
180
+ res = tokenizer.batch_decode(res, skip_special_tokens=True)
181
+ print(res)
182
+ # ["И не ясно прохожим в этот день непогожий, почему я веселый такой."]
183
+ ```
184
+
185
+ ## Limitations
186
+ - The model is intended to be fine-tuned on sets with natural errors for better performance. The realized model is a pre-train and pre-train task is different from the usual spell checking in terms of density of the noise in a corpus and its origin;
187
+ - Complex formatting may cause some trouble in output generation.
188
+
189
+ ## Resources
190
+ - [SAGE library](https://github.com/ai-forever/sage), GitHub
191
+ - [sage-fredt5-large](https://huggingface.co/ai-forever/sage-fredt5-large), HuggingFace
192
+ - [sage-fredt5-distilled-95m](https://huggingface.co/ai-forever/sage-fredt5-distilled-95m), HuggingFace
193
+ - [sage-m2m100-1.2B](https://huggingface.co/ai-forever/sage-m2m100-1.2B), HuggingFace
194
+ - [sage-mt5-large](https://huggingface.co/ai-forever/sage-mt5-large), HuggingFace
195
+
196
+ ## License
197
+ Model [FRED-T5-large](https://huggingface.co/ai-forever/FRED-T5-large), on the basis of which our solution is made, and its source code are supplied under the MIT license.
198
+ Our solution comes with MIT license also.
199
+
200
+ ## Specifications
201
+ - File size: 3.3 Gb;
202
+ - Framework: pytorch
203
+ - Version: v1.0
204
+ - Developer: SberDevices, AGI NLP
205
+
206
+ ## Contacts
207
+ nikita.martynov.98@list.ru