Hatim2221 / Mubsir-vl-arabic-htr-adapter

huggingface.co
Total runs: 0
24-hour runs: 0
7-day runs: 0
30-day runs: 0
Model's Last Updated: August 15 2026
image-to-text

Introduction of Mubsir-vl-arabic-htr-adapter

Model Details of Mubsir-vl-arabic-htr-adapter

Mubsir — Arabic Handwritten Text Recognition (HTR) Adapter

Mubsir (مُبصِر — "one who sees clearly") is a QLoRA adapter that fine-tunes Qwen2-VL-2B-Instruct for Arabic handwritten text recognition. Given an image of unstructured Arabic handwriting, the model outputs an accurate digital transcript.

This repository contains the standalone LoRA adapter weights only . For a ready-to-use, fully merged 16-bit model, see Hatim2221/Mubsir-Qwen-2B-VL .

Model Details
Base model Qwen/Qwen2-VL-2B-Instruct
Task Image-to-text / Handwritten Text Recognition (HTR)
Language Arabic (ar)
Fine-tuning method QLoRA (Parameter-Efficient Fine-Tuning)
Training dataset KHATT (KFUPM Handwritten Arabic TexT)
Adapter format PEFT / LoRA
License Apache 2.0
Training Setup
  • Hardware: Kaggle Notebooks, 2× NVIDIA T4 GPUs
  • Frameworks: PyTorch, transformers , peft , accelerate , qwen-vl-utils
  • Trainer: Native Hugging Face Trainer (used in place of SFTTrainer to avoid library versioning conflicts in the Kaggle environment)
  • Memory management: PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True , capped dynamic image resolution, and reduced batch sizes to fit multimodal fine-tuning within T4 VRAM limits without OOM failures
Usage

The adapter must be attached to the base model at full precision. Loading the 4-bit quantized base and merging the 16-bit adapter directly in VRAM introduces rounding errors and degrades transcription quality — load the base model in torch.float16 instead.

pip install -U transformers peft accelerate qwen-vl-utils "torchao>0.16.0"
import torch
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
from peft import PeftModel
from qwen_vl_utils import process_vision_info

base_model_id = "Qwen/Qwen2-VL-2B-Instruct"
adapter_id = "Hatim2221/Mubsir-vl-arabic-htr-adapter"

# Load base model in float16 (do NOT load in 4-bit for merging/inference)
model = Qwen2VLForConditionalGeneration.from_pretrained(
    base_model_id,
    torch_dtype=torch.float16,
    device_map="auto",
)
processor = AutoProcessor.from_pretrained(base_model_id)

# Attach the LoRA adapter
model = PeftModel.from_pretrained(model, adapter_id)
model.eval()

messages = [
    {
        "role": "user",
        "content": [
            {"type": "image", "image": "path/to/handwritten_image.jpg"},
            {"type": "text", "text": "Transcribe the Arabic handwritten text in this image."},
        ],
    }
]

text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
image_inputs, video_inputs = process_vision_info(messages)

inputs = processor(
    text=[text],
    images=image_inputs,
    videos=video_inputs,
    padding=True,
    return_tensors="pt",
).to(model.device)

generated_ids = model.generate(**inputs, max_new_tokens=512)
generated_ids_trimmed = [
    out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
    generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)

print(output_text[0])
Merging the adapter yourself

If you want to produce your own merged, standalone checkpoint instead of using the pre-merged Hatim2221/Mubsir-Qwen-2B-VL :

merged_model = model.merge_and_unload()
merged_model.save_pretrained("mubsir-merged-fp16")
processor.save_pretrained("mubsir-merged-fp16")

Always merge from a float16 (or bfloat16 ) base — merging into a 4-bit quantized base will silently corrupt the adapter's learned weights.

Intended Use
  • Digitizing Arabic handwritten documents, notes, and manuscripts
  • Research and benchmarking on Arabic HTR
  • As a base for further fine-tuning on domain-specific handwriting (e.g., historical manuscripts, forms, exam scripts)
Limitations
  • Trained on the KHATT dataset; performance may degrade on handwriting styles, scripts, or document layouts (e.g., dense marginalia, mixed-language text) that differ significantly from the training distribution.
  • As with any HTR system, accuracy depends on image quality — resolution, lighting, and skew can affect output.
  • Not evaluated for languages or scripts other than Arabic.
Citation

If you use this adapter, please consider citing the base model and the KHATT dataset:

@misc{qwen2vl,
  title={Qwen2-VL},
  author={Qwen Team},
  year={2024},
  url={https://huggingface.co/Qwen/Qwen2-VL-2B-Instruct}
}
Acknowledgements

Runs of Hatim2221 Mubsir-vl-arabic-htr-adapter on huggingface.co

0
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs

More Information About Mubsir-vl-arabic-htr-adapter huggingface.co Model

More Mubsir-vl-arabic-htr-adapter license Visit here:

https://choosealicense.com/licenses/apache-2.0

Mubsir-vl-arabic-htr-adapter huggingface.co

Mubsir-vl-arabic-htr-adapter huggingface.co is an AI model on huggingface.co that provides Mubsir-vl-arabic-htr-adapter's model effect (), which can be used instantly with this Hatim2221 Mubsir-vl-arabic-htr-adapter model. huggingface.co supports a free trial of the Mubsir-vl-arabic-htr-adapter model, and also provides paid use of the Mubsir-vl-arabic-htr-adapter. Support call Mubsir-vl-arabic-htr-adapter model through api, including Node.js, Python, http.

Mubsir-vl-arabic-htr-adapter huggingface.co Url

https://huggingface.co/Hatim2221/Mubsir-vl-arabic-htr-adapter

Hatim2221 Mubsir-vl-arabic-htr-adapter online free

Mubsir-vl-arabic-htr-adapter huggingface.co is an online trial and call api platform, which integrates Mubsir-vl-arabic-htr-adapter's modeling effects, including api services, and provides a free online trial of Mubsir-vl-arabic-htr-adapter, you can try Mubsir-vl-arabic-htr-adapter online for free by clicking the link below.

Hatim2221 Mubsir-vl-arabic-htr-adapter online free url in huggingface.co:

https://huggingface.co/Hatim2221/Mubsir-vl-arabic-htr-adapter

Mubsir-vl-arabic-htr-adapter install

Mubsir-vl-arabic-htr-adapter is an open source model from GitHub that offers a free installation service, and any user can find Mubsir-vl-arabic-htr-adapter on GitHub to install. At the same time, huggingface.co provides the effect of Mubsir-vl-arabic-htr-adapter install, users can directly use Mubsir-vl-arabic-htr-adapter installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

Mubsir-vl-arabic-htr-adapter install url in huggingface.co:

https://huggingface.co/Hatim2221/Mubsir-vl-arabic-htr-adapter

Url of Mubsir-vl-arabic-htr-adapter

Mubsir-vl-arabic-htr-adapter huggingface.co Url

Provider of Mubsir-vl-arabic-htr-adapter huggingface.co

Hatim2221
ORGANIZATIONS

Other API from Hatim2221