File size: 2,496 Bytes
ab704d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
\---

license: apache-2.0

base\_model: t5-small



tags:



  - grammar-correction



  - t5



  - text2text-generation



language:



  - en



\---







\# Proximity Grammar Corrector (T5-small)







A small fine-tuned \[T5-small](https://huggingface.co/t5-small) model for \*\*English grammar correction\*\*. Part of the \[Proximity](https://github.com/) project — a lightweight background tool that fixes grammar via a global hotkey.







\## What this model does







Takes a sentence with grammar mistakes and outputs a corrected version. Examples:







| Input | Output |



|---|---|



| She dont like going to the store. | She doesn't like going to the store. |



| He are moving here. | He is moving here. |



| I has went to the market yesterday. | I have gone to the market yesterday. |



| They was happy about they new house. | They were happy about their new house. |







\## What this model does NOT do







\- It is \*\*not a chat model\*\*. It will not hold a conversation or answer questions.



\- It is \*\*not a style/tone rewriter\*\*. It targets grammatical correctness, not voice or wording improvements.



\- It struggles with some irregular verb forms not well represented in training data (e.g. "drinked" instead of "drank" was not corrected in testing).



\- It is trained on a small dataset (\~6,000 sentence pairs), so coverage of rare or complex grammatical errors is limited.







\## Training details







\- \*\*Base model:\*\* t5-small (\~60M parameters)



\- \*\*Dataset:\*\* \[Owishiboo/grammar-correction](https://huggingface.co/datasets/Owishiboo/grammar-correction) (\~6,000 ungrammatical → grammatical sentence pairs)



\- \*\*Epochs:\*\* 6



\- \*\*Final train loss:\*\* 0.1685



\- \*\*Final eval loss:\*\* \~0.186







\## Usage







```python



from transformers import T5Tokenizer, T5ForConditionalGeneration







tokenizer = T5Tokenizer.from\_pretrained("EnderAir/proximity")

model = T5ForConditionalGeneration.from\_pretrained("EnderAir/proximity")







text = "grammar: He are moving here."



inputs = tokenizer(text, return\_tensors="pt")

outputs = model.generate(\*\*inputs, max\_length=64, num\_beams=5)

print(tokenizer.decode(outputs\[0], skip\_special\_tokens=True))

\# "He is moving here."

```







Note: always prefix input text with `"grammar: "` — this is the T5 task prefix convention used during training.







\## License







Apache 2.0