File size: 2,224 Bytes
9bf4da4
 
91b0200
 
 
 
 
 
 
9bf4da4
91b0200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
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