alakxender/dv-synthetic-errors-mixed
Viewer • Updated • 19M • 22
How to use alakxender/dhivehi-quick-spell-check-t5 with Transformers:
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("alakxender/dhivehi-quick-spell-check-t5")
model = AutoModelForSeq2SeqLM.from_pretrained("alakxender/dhivehi-quick-spell-check-t5", device_map="auto")A fine-tuned T5 model for correcting typos in Dhivehi text. This project uses a custom-trained T5-small model to detect and fix spelling errors in Dhivehi text.
This project implements a spell-checking system using:
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import torch
# Load the model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("alakxender/dhivehi-quick-spell-check-t5")
model = AutoModelForSeq2SeqLM.from_pretrained("alakxender/dhivehi-quick-spell-check-t5")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
# Correct text
def correct_text(input_text):
input_text = "fix: " + input_text
inputs = tokenizer(input_text, return_tensors="pt", max_length=128, truncation=True)
inputs = inputs.to(device)
outputs = model.generate(
input_ids=inputs["input_ids"],
attention_mask=inputs.get("attention_mask", None),
max_length=128,
num_beams=4,
early_stopping=True
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
Base model
google-t5/t5-small