This repository contains LoRA adapter weights fine-tuned for English grammar correction.
The adapters are trained on top of the LiquidAI/LFM2.5-1.2B-Instruct base model using QLoRA.
The model is designed to:
Correct grammatical errors
Preserve the original meaning
Minimize unnecessary rewrites
This repository does not contain the base model weights, only the LoRA adapters.
⚠️ About Hugging Face Auto-Generated Code Snippets
1from transformers import pipeline
23# Use our predefined prompt template4sentence ="""Write this sentence correctly: Here was no promise of morning except that we looked up through the trees we saw how low the forest had swung .
5"""6dic1 =[{'role':"user",'content': sentence}]78prompt = tokenizer.apply_chat_template(dic1, tokenize=False, add_generation_prompt=True)9# Run our instruction-tuned model10pipe = pipeline(task="text-generation", model=merged_model, tokenizer=tokenizer)11print(pipe(prompt)[0]["generated_text"])
Training Details
Training Data
JFLEG (JHU Fluency-Extended GUG Corpus)
Dataset focused on grammatical error correction with multiple human references
Training Procedure
Preprocessing
Inputs formatted using the base model’s chat template
Each example consists of an erroneous sentence and a corrected version
Training Hyperparameters
Training regime: Supervised Fine-Tuning (SFT)
Method: QLoRA
Precision: 4-bit (NF4)
Max sequence length: 512 tokens
Optimizer: AdamW (via TRL)
PEFT: LoRA
Speeds, Sizes, Times
Training performed on a single GPU
Lightweight adapter-only training
Evaluation
Testing Data
Held-out samples from JFLEG
Custom manually written grammatical error examples
Factors
Error type (tense, agreement, articles, prepositions)
Sentence length
Error density
Metrics
Training loss (cross-entropy)
Qualitative human evaluation
(Optional) GLEU score
Results
Rapid loss convergence
High-quality grammatical corrections
Minimal semantic drift
Summary
Model Examination
The model demonstrates strong grammatical correction capabilities while preserving sentence meaning.
It performs best on common ESL-style grammatical errors.
Environmental Impact
Hardware Type: NVIDIA GPU (single device)
Hours Used: < 5 hours
Cloud Provider: Google Colab
Compute Region: Not specified
Carbon Emitted: Not estimated
Technical Specifications
Model Architecture and Objective
Base architecture: Transformer-based causal language model
Objective: Next-token prediction for grammar-corrected text