inkoziev commited on
Commit
a26bf8e
·
verified ·
1 Parent(s): d3c5e79

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +77 -3
README.md CHANGED
@@ -1,3 +1,77 @@
1
- ---
2
- license: cc-by-nc-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ language:
4
+ - ru
5
+ base_model:
6
+ - ai-forever/FRED-T5-1.7B
7
+ ---
8
+
9
+ # Grammatical Error Detection for Russian
10
+
11
+ This model detects grammatical errors, misspellings, and typos in Russian text, as detailed in the preprint [arXiv:2505.04507v1](https://arxiv.org/abs/2505.04507).
12
+
13
+ ## Model Functionality
14
+
15
+ - **Task:** Binary classification for the presence of defects in text.
16
+ - **Input:** Russian text, which can range from a single sentence to a full paragraph.
17
+ - **Output:** `True` if any errors are detected; `False` if the text is error-free.
18
+
19
+ ## Key Notes
20
+
21
+ - The model is designed to handle multi-sentence context.
22
+ - It only performs detection and provides a binary output. It does not locate the specific errors or suggest corrections.
23
+
24
+ ## Usage example
25
+
26
+ ```python
27
+ import torch
28
+ import transformers
29
+
30
+ ged_model_path = "inkoziev/ged-FRED-T5-1.7B"
31
+ ged_tokenizer = transformers.AutoTokenizer.from_pretrained(ged_model_path)
32
+ ged_model = transformers.T5ForConditionalGeneration.from_pretrained(ged_model_path, device_map='cuda:0', torch_dtype=torch.half)
33
+
34
+ # Input texts to check against grammatical or orthographical defects.
35
+ input_texts = ["Расскажу как настроить плагин и сделать быструю домашнюю страничку, расскажу как найти продвинутые гайды для создания сверх-эстетичной домашней страничке.",
36
+ "Расскажу, как настроить плагин и сделать быструю домашнюю страничку, расскажу, как найти продвинутые гайды для создания сверхэстетичной домашней странички."]
37
+
38
+ # Construct an instructive prompt.
39
+ prepend_prompt = "<LM>Проанализируй заданный ниже текст. Идентифицируй в нем грамматические и орфографические ошибки. Если есть хотя бы одна такая ошибка, то выведи 'True'. Если текст не содержит грамматических и орфографических ошибок, выведи 'False'.\n\nТекст: "
40
+
41
+ xx = ged_tokenizer([(prepend_prompt + input_text) for input_text in input_texts],
42
+ truncation=False,
43
+ padding="longest",
44
+ return_tensors='pt').to(ged_model.device)
45
+ out_ids = ged_model.generate(input_ids=xx.input_ids, eos_token_id=ged_tokenizer.eos_token_id, max_length=5)
46
+
47
+ # The model returns "True" or "False" text for each input row.
48
+ for input_text, has_defects in zip(input_texts, out_ids.cpu().tolist()):
49
+ has_defects = has_defects[1:has_defects.index(ged_tokenizer.eos_token_id)]
50
+ has_defects = ged_tokenizer.decode(has_defects)
51
+ print(f"{input_text} ==> {has_defects}")
52
+ ```
53
+
54
+ The output should be:
55
+
56
+ ```
57
+ Расскажу как настроить плагин и сделать быструю домашнюю страничку, расскажу как найти продвинутые гайды для создания сверх-эстетичной домашней страничке. ==> True
58
+ Расскажу, как настроить плагин и сделать быструю домашнюю страничку, расскажу, как найти продвинутые гайды для создания сверхэстетичной домашней странички. ==> False
59
+ ```
60
+
61
+ ## Metrics
62
+
63
+ The model was evaluated on the RUPOR dataset (which is not yet public) and on several open-source datasets:
64
+
65
+ | Domain | Population | F<sub>1</sub> | F<sub>0.5</sub> | Precision | Recall |
66
+ | ------------------------ | ---------- | ------------- | --------------- | --------- | ------ |
67
+ | RUPOR poetry | 4508 | 0.838 | 0.88 | 0.911 | 0.776 |
68
+ | RUPOR prose | 3998 | 0.882 | 0.911 | 0.932 | 0.837 |
69
+ | RuCoLa | 3998 | 0.268 | 0.464 | 0.905 | 0.158 |
70
+ | RuBLiMP | 3992 | 0.948 | 0.943 | 0.94 | 0.956 |
71
+ | rlc-toloka (ru) | 3992 | 0.801 | 0.846 | 0.878 | 0.737 |
72
+ | SAGE MultidomainGold | 2133 | 0.858 | 0.911 | 0.951 | 0.782 |
73
+ | SAGE RUSpellRU | 1233 | 0.941 | 0.963 | 0.979 | 0.906 |
74
+ | SAGE MedSpellchecker | 325 | 0.969 | 0.983 | 0.993 | 0.947 |
75
+ | SAGE GitHubTypoCorpusRu | 307 | 0.782 | 0.84 | 0.883 | 0.702 |
76
+
77
+