This model is part of the Gramformer library please refer to https://github.com/PrithivirajDamodaran/Gramformer/
Gramformer
Human and machine-generated text often suffer from grammatical and/or typographical errors. It can be spelling, punctuation, grammatical or word choice errors. Gramformer is a library that exposes 3 separate interfaces to a family of algorithms to detect, highlight and correct grammar errors. To make sure the corrections and highlights recommended are of high quality, it comes with a quality estimator. You can use Gramformer in one or more areas mentioned under the "use-cases" section below or any other use case as you see fit. Gramformer stands on the shoulders of giants, it combines some of the top-notch researches in grammar correction. Note: It works at sentence levels and has been trained on 128 length sentences, so not (yet) suitable for long prose or paragraphs (stay tuned for upcoming releases)
Usecases for Gramformer
Area 1: Post-processing machine-generated text
Machine-Language generation is becoming mainstream, so will post-processing machine-generated text.
- Conditioned Text generation output(Text2Text generation).
- NMT: Machine Translated output.
- ASR or STT: Speech to text output.
- HTR: Handwritten text recognition output.
- Paraphrase generation output.
- Controlled Text generation output(Text generation with PPLM) [TBD].
- Free-form text generation output(Text generation)[TBD].
Area 2:Human-In-The-Loop (HITL) text
- Most Supervised NLU (Chatbots and Conversational) systems need humans/experts to enter or edit text that needs to be grammatically correct otherwise the quality of HITL data can degrade the model over a period of time
Area 3:Assisted writing for humans
- Integrating into custom Text editors of your Apps. (A Poor man's grammarly, if you will)
Area 4:Custom Platform integration
As of today grammatical safety nets for authoring social contents (Post or Comments) or text in messaging platforms is very little (word level correction) or non-existent.The onus is on the author to install tools like grammarly to proof read.
- Messaging platforms and Social platforms can highlight / correct grammtical errors automatically without altering the meaning or intent.
Installation
pip install git+https://github.com/PrithivirajDamodaran/Gramformer.git@v0.1
Quick Start
Correcter - [Available now]
from gramformer import Gramformer
import torch
def set_seed(seed):
torch.manual_seed(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed_all(seed)
set_seed(1212)
gf = Gramformer(models = 2, use_gpu=False) # 0=detector, 1=highlighter, 2=corrector, 3=all
influent_sentences = [
"Matt like fish",
"the collection of letters was original used by the ancient Romans",
"We enjoys horror movies",
"Anna and Mike is going skiing",
"I walk to the store and I bought milk",
"We all eat the fish and then made dessert",
"I will eat fish for dinner and drank milk",
"what be the reason for everyone leave the company",
]
for influent_sentence in influent_sentences:
corrected_sentence = gf.correct(influent_sentence)
print("[Input] ", influent_sentence)
print("[Correction] ",corrected_sentence[0])
print("-" *100)
[Input] Matt like fish
[Correction] Matt likes fish
----------------------------------------------------------------------------------------------------
[Input] the collection of letters was original used by the ancient Romans
[Correction] The collection of letters was originally used by the ancient Romans.
----------------------------------------------------------------------------------------------------
[Input] We enjoys horror movies
[Correction] We enjoy horror movies
----------------------------------------------------------------------------------------------------
[Input] Anna and Mike is going skiing
[Correction] Anna and Mike are going skiing
----------------------------------------------------------------------------------------------------
[Input] I walk to the store and I bought milk
[Correction] I walked to the store and bought milk.
----------------------------------------------------------------------------------------------------
[Input] We all eat the fish and then made dessert
[Correction] We all ate the fish and then made dessert
----------------------------------------------------------------------------------------------------
[Input] I will eat fish for dinner and drank milk
[Correction] I'll eat fish for dinner and drink milk.
----------------------------------------------------------------------------------------------------
[Input] what be the reason for everyone leave the company
[Correction] what can be the reason for everyone to leave the company.
----------------------------------------------------------------------------------------------------