You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Llama 3.1 8B Instruct Fine-tuned for Sinhala Spell Correction

A Llama 3.1 8B Instruct model fine-tuned for Sinhala spell correction using LoRA as part of the LMSpell project.

Model Details

  • Base model: unsloth/meta-llama-3.1-8b-instruct-bnb-4bit
  • Model type: LoRA adapter
  • Language: Sinhala (si)
  • Task: Sinhala Spell Correction (SSC)
  • Training method: Supervised Fine-Tuning (SFT) with LoRA
  • Dataset: Sinhala Spell Correction Dataset
  • License: CC BY 4.0
  • Project: LMSpell

Uses

Direct Use

The model can be used to correct spelling errors in Sinhala text.

Out-of-Scope Use

The model is not intended for languages other than Sinhala or for tasks unrelated to spell correction.

Limitations

  • Performance may vary across different domains and text styles.
  • The model may occasionally modify text that is already correctly spelled.
  • Performance may be lower on informal, code-mixed, or domain-specific text.

How to Get Started

### 1. Model Loading

#### Using Unsloth

```python
from unsloth import FastLanguageModel

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="lm-spell/llama-3.1-8b-it-ft-ssc"
)

tokenizer.pad_token = tokenizer.eos_token

FastLanguageModel.for_inference(model)

Using Transformers and PEFT

from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel

adapter_name = "lm-spell/llama-3.1-8b-it-ft-ssc"
base_model =  "unsloth/meta-llama-3.1-8b-instruct-bnb-4bit"

tokenizer = AutoTokenizer.from_pretrained(adapter_name)

model = AutoModelForCausalLM.from_pretrained(
    base_model
)

model = PeftModel.from_pretrained(
    model,
    adapter_name
)

tokenizer.pad_token = tokenizer.eos_token

2. Inference

import re

def clean_text(text):
    match = re.search(r'### Output:\n(.*)', text, re.DOTALL)
    if match:
        return match.group(1).replace("Text:\n", "").replace("Output:\n", "").replace("###", "").strip()
    return text.strip()

alpaca_prompt = f"""You are an Expert Sinhala Spell Corrector. Below is a sentence in Sinhala Language. It may or may not have a spelling mistake. Give the corrected output in Sinhala.

### Text:
{{}}

### Output:
{{}}"""

text = "යින් හැඟෙන්නේ පවත්නා අධ්‍යාපන ක්‍රමයේ පවතින උසස මට්ටමය ."

inputs = tokenizer(
    [alpaca_prompt.format("", text)],
    return_tensors="pt"
) # .to("cuda") if using unsloth

outputs = model.generate(**inputs)

pred_text = tokenizer.decode(
    outputs[0],
    skip_special_tokens=True
)

print(clean_text(pred_text))

Training Details

Training Data

The model was fine-tuned using the Sinhala Spell Correction Dataset.

Training Procedure

The model was fine-tuned using Supervised Fine-Tuning (SFT) with LoRA using Unsloth.

Evaluation

The model was evaluated for Sinhala spell correction using the evaluation datasets and metrics described in the LMSpell paper.

For detailed training methodology, dataset preparation, evaluation results, and comparisons with other models, please refer to the paper.

Research

LMSpell: Spell Correction with Pre-Trained Language Models

A. Gunathilake, N. Karunarathna, T. Bandaranayake, S. Ranathunga, N. de Silva and N. Jayatilleke, "LMSpell: Spell Correction with Pre-Trained Language Models," 2026 Moratuwa Engineering Research Conference (MERCon), Moratuwa, Sri Lanka, 2026, pp. 503-508.

Citation

@INPROCEEDINGS{11691371,
  author={Gunathilake, Akesh and Karunarathna, Nadil and Bandaranayake, Tharusha and Ranathunga, Surangika and de Silva, Nisansa and Jayatilleke, Nevidu},
  booktitle={2026 Moratuwa Engineering Research Conference (MERCon)},
  title={LMSpell: Spell Correction with Pre-Trained Language Models},
  year={2026},
  pages={503-508},
  doi={10.1109/MERCon71835.2026.11691371}
}

Framework Versions

  • PEFT: 0.17.1
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train lm-spell/llama-3.1-8b-it-ft-ssc