Downloads · 30 days
29
25% of all-time downloads
lgtk/qwen25vl-3b-modi-lora
qwen25vl-3b-modi-lora is a machine learning model from lgtk. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
A QLoRA adapter for Modi script → Devanagari (Marathi) transliteration, fine-tuned on the MoDeTrans dataset (real handwritten Modi document images with expert-verified Devanagari text).
Downloads · 30 days
29
25% of all-time downloads
All-time downloads
118
Public
Repo size
309 MB
Likes
0
Public
Click a slice to open those files.
.safetensors297 MB · 96%
From the Hugging Face model README
A QLoRA adapter for Modi script → Devanagari (Marathi) transliteration, fine-tuned on the MoDeTrans dataset (real handwritten Modi document images with expert-verified Devanagari text).
Recommended model:
lgtk/qwen25vl-3b-modi-synth-loraadds synthetic training data and achieves a slightly lower CER (0.328 vs 0.332). Use this adapter if you want the real-data-only baseline.
Project: modi-to-Marathi on GitHub
| Base model | Qwen/Qwen2.5-VL-3B-Instruct |
| Fine-tuning method | QLoRA — LoRA rank 32, alpha 64, 4-bit NF4 quantization |
| LoRA target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Trainable parameters | 74M (1.94% of 3.8B total) |
| Training data | MoDeTrans — 1,635 real document images (80/10/10 split, seed=42) |
| Training epochs | 3 |
| Training time | ~7.5 hours on RTX 5060 (8.5 GB VRAM) |
| Test CER | 0.332 (on 204 held-out MoDeTrans examples) |
| Zero-shot baseline CER | 0.930 |
A CER of 0.332 means approximately 33% of characters require expert correction — suitable as a first-draft assistant in a human-in-the-loop workflow.
Input: photograph or scan of a handwritten Modi-script Marathi document Output: Devanagari transliteration of that text
This is transliteration, not translation — the language (Marathi) does not change, only the script. Modi was the administrative script of Maharashtra from roughly the 13th to the mid-20th century; most surviving documents are from the Shivakalin (17th c.), Peshwekalin (18th–early 19th c.), and Anglakalin (1818–1952) eras.
Install dependencies:
pip install transformers peft bitsandbytes accelerate pillow torch
from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor, BitsAndBytesConfig
from peft import PeftModel
from PIL import Image
import torch
MODEL_ID = "Qwen/Qwen2.5-VL-3B-Instruct"
ADAPTER_ID = "lgtk/qwen25vl-3b-modi-lora" # ← this repo
bnb = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
)
base = Qwen2_5_VLForConditionalGeneration.from_pretrained(
MODEL_ID, quantization_config=bnb, device_map="auto")
model = PeftModel.from_pretrained(base, ADAPTER_ID)
model.eval()
processor = AutoProcessor.from_pretrained(MODEL_ID, max_pixels=512 * 28 * 28)
PROMPT = (
"This image contains handwritten text in Modi script, a historical cursive "
"script used to write the Marathi language. "
"Transliterate the text in this image into Devanagari script. "
"Output only the Devanagari text, with no explanation."
)
image = Image.open("your_modi_image.jpg").convert("RGB")
messages = [{
"role": "user",
"content": [
{{"type": "image", "image": image}},
{{"type": "text", "text": PROMPT}},
],
}]
text_in = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text_in], images=[image], return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(**inputs, max_new_tokens=256, do_sample=False)
result = processor.batch_decode(
out[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True
)[0].strip()
print(result)
Developed and tested on a desktop with an NVIDIA RTX 5060 GPU (8.5 GB VRAM) running WSL2 on Windows. At 4-bit NF4 quantization, the adapter uses approximately 3–4 GB of VRAM during inference. A 5060 or better is recommended; the pipeline should also fit on any GPU with ≥6 GB VRAM.
historyHulk/MoDeTrans on HuggingFace