deep-learning-analytics commited on
Commit
d2eb05f
1 Parent(s): d870b6d

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +37 -0
README.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Model description
2
+ T5 model trained for Grammar Correction. This model corrects grammatical mistakes in input sentences
3
+
4
+ ### Dataset Description
5
+ The T5-base model has been trained on C4_200M dataset.
6
+ ### Model in Action 🚀
7
+ ```
8
+ import torch
9
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
10
+ model_name = 'deep-learning-analytics/GrammarCorrector'
11
+ torch_device = 'cuda' if torch.cuda.is_available() else 'cpu'
12
+ tokenizer = T5Tokenizer.from_pretrained(model_name)
13
+ model = T5ForConditionalGeneration.from_pretrained(model_name).to(torch_device)
14
+
15
+ def correct_grammar(input_text,num_return_sequences):
16
+ batch = tokenizer([input_text],truncation=True,padding='max_length',max_length=64, return_tensors="pt").to(torch_device)
17
+ translated = model.generate(**batch,max_length=64,num_beams=num_beams, num_return_sequences=num_return_sequences, temperature=1.5)
18
+ tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True)
19
+ return tgt_text
20
+
21
+ ```
22
+
23
+ ### Example Usage
24
+ ```
25
+ text = 'He are moving here.'
26
+ print(correct_grammar(text, num_return_sequences=2))
27
+ ['He is moving here.', 'He is moving here now.']
28
+ ```
29
+
30
+ Another example
31
+ ```
32
+ text = 'Cat drinked milk'
33
+ print(correct_grammar(text, num_return_sequences=2))
34
+ ['Cat drank milk.', 'Cat drink milk.']
35
+ ```
36
+
37
+ Model Developed by [Priya-Dwivedi](https://www.linkedin.com/in/priyanka-dwivedi-6864362)