Downloads · 30 days
9
9% of all-time downloads
ionut-visan/Flan-T5-Large_Grammar_Ro
Flan-T5-Large_Grammar_Ro is a machine learning model from ionut-visan. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as cc-by-nc-4.0.
<h5 style="font-family: 'Calibri'; margin-bottom: 20px;" <a href="https://huggingface.co/google/flan-t5-large" target="blank"Flan-T5-Large</a is an instruction-tuned language model that treats all NLP tasks as text-to…
Downloads · 30 days
9
9% of all-time downloads
All-time downloads
100
Public
Parameters
783M
3.1 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors3.1 GB · 100%
From the Hugging Face model README
<img src="https://huggingface.co/ionut-visan/Flan-T5-Large_Grammar_Ro/resolve/main/loss_plot.png" alt="Error Rates Plot" width="350" style="margin-left: 10px;"> <img src="https://huggingface.co/ionut-visan/Flan-T5-Large_Grammar_Ro/resolve/main/error_rates_plot.png" alt="Loss Plot" width="350" style="margin-left: 10px;"> <img src="https://huggingface.co/ionut-visan/Flan-T5-Large_Grammar_Ro/resolve/main/learning_rate_plot.png" alt="Loss Plot" width="350" style="margin-left: 10px;"> <img src="https://huggingface.co/ionut-visan/Flan-T5-Large_Grammar_Ro/resolve/main/bleu_plot.png" alt="Loss Plot" width="350" style="margin-left: 10px;"> <img src="https://huggingface.co/ionut-visan/Flan-T5-Large_Grammar_Ro/resolve/main/gleu_plot.png" alt="Loss Plot" width="350" style="margin-left: 10px;"> <img src="https://huggingface.co/ionut-visan/Flan-T5-Large_Grammar_Ro/resolve/main/rouge1_plot.png" alt="Loss Plot" width="350" style="margin-left: 10px;"> <img src="https://huggingface.co/ionut-visan/Flan-T5-Large_Grammar_Ro/resolve/main/rouge2_plot.png" alt="Loss Plot" width="350" style="margin-left: 10px;"> <img src="https://huggingface.co/ionut-visan/Flan-T5-Large_Grammar_Ro/resolve/main/rougeL_plot.png" alt="Loss Plot" width="350" style="margin-left: 10px;">
<h5 style="font-family: 'Calibri'; margin-bottom: 5px;"> The fine-tuned model was saved at epoch 5 with Test Loss: 0.3151, WER: 0.0893, CER: 0.0304, BLEU: 0.8424, GLEU: 0.8405, ROUGE-1: 0.9294, ROUGE-2: 0.8723, ROUGE-L: 0.9279. </h5>import torch
from transformers import T5Tokenizer, T5ForConditionalGeneration
# Set device
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Load model and tokenizer
model_name = "ionut-visan/Flan-T5-Large_Grammar_Ro"
tokenizer = T5Tokenizer.from_pretrained(model_name)
model = T5ForConditionalGeneration.from_pretrained(model_name).to(device)
model.eval()
# Function to correct grammar
def correct_sentence(sentence):
input_text = "grammar: " + sentence
inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
with torch.no_grad():
outputs = model.generate(inputs, max_length=128, num_beams=4, early_stopping=True)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# Interactive loop
print("Romanian Grammar Corrector (type 'exit' to quit)")
while True:
user_input = input("\nEnter a sentence to correct: ")
if user_input.lower() == "exit":
print("Exiting. 👋")
break
corrected = correct_sentence(user_input)
print("Corrected:", corrected)