Grammarly_Space / app.py
ColeGuion's picture
Update app.py
8e967a1 verified
raw
history blame
882 Bytes
import gradio as gr
from transformers import pipeline
def correct_text(text, temperature=1.0, top_p=0.9, top_k=50):
model_id = "grammarly/coedit-large"
pipe = pipeline("text2text-generation", model=model_id,
generation_kwargs={"temperature": temperature, "top_p": top_p, "top_k": top_k})
corrected = pipe(text)[0]['generated_text']
return corrected
interface = gr.Interface(fn=correct_text,
inputs=[gr.inputs.TextArea(label="Input Text"),
gr.inputs.Slider(minimum=0.1, maximum=1.0, default=1.0, label="Temperature"),
gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.9, label="Top_p"),
gr.inputs.Slider(minimum=0, maximum=100, default=50, label="Top_k")],
outputs="text")
interface.launch()