File size: 1,786 Bytes
d408ee2
 
 
 
 
 
 
 
90a810f
d408ee2
 
 
 
 
 
 
 
 
 
dbac39f
d408ee2
 
 
 
 
 
367ff93
d408ee2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f9aad7c
5260ab4
d408ee2
f9aad7c
d408ee2
dbac39f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---



language: en

tags:

- sentence correction

- text2text-generation

license: cc-by-nc-sa-4.0

datasets:

- jfleg

---


# Model
This model utilises T5-base sentence correction pre-trained model. It was fine tuned using a modified version of the [JFLEG](https://arxiv.org/abs/1702.04066) dataset and [Happy Transformer framework](https://github.com/EricFillion/happy-transformer). This model was pre-trained for educational purposes only for correction on local Caribbean dialect. For more on Caribbean dialect checkout the library [Caribe](https://pypi.org/project/Caribe/).
.
___





# Re-training/Fine Tuning



The results of fine-tuning resulted in a final accuracy of 90%





# Usage 







```python



from happytransformer import HappyTextToText, TTSettings



pre_trained_model="T5"

model = HappyTextToText(pre_trained_model, "KES/T5-KES")



arguments = TTSettings(num_beams=4, min_length=1)

sentence = "Wat iz your nam"



correction = model.generate_text("grammar: "+sentence, args=arguments)

if(correction.text.find(" .")):

    correction.text=correction.text.replace(" .", ".")



print(correction.text) # Correction: "What is your name?".



```

_

# Usage with Transformers



```python



from transformers import AutoTokenizer, AutoModelForSeq2SeqLM



tokenizer = AutoTokenizer.from_pretrained("KES/T5-KES")



model = AutoModelForSeq2SeqLM.from_pretrained("KES/T5-KES")



text = "I am lived with my parenmts "

inputs = tokenizer("grammar:"+text, truncation=True, return_tensors='pt')



output = model.generate(inputs['input_ids'], num_beams=4, max_length=512, early_stopping=True)

correction=tokenizer.batch_decode(output, skip_special_tokens=True)

print("".join(correction)) #Correction: I am living with my parents.



```