Instructions to use furkancmc/kadim-ocr-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use furkancmc/kadim-ocr-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("/content/drive/MyDrive/qwen_vl_7b_model") model = PeftModel.from_pretrained(base_model, "furkancmc/kadim-ocr-lora") - Notebooks
- Google Colab
- Kaggle
KADİM OCR LoRA (kadim-ocr-lora)
A LoRA adapter for Qwen2.5-VL-7B-Instruct that reads Turkish document images and returns their text. It cuts the character error rate from 0.428 to 0.108 on a held-out set of degraded scans, with the largest gains on Turkish-specific letters (ı, ş, ğ, ö, ü, ç).
It is the reader (OCR) component of KADİM — Kamu Dilekçe ve İnceleme Mekanizması, an end-to-end agent system for public-sector correspondence built for the TEKNOFEST 2026 Language Agents Competition (Scenario 1).
- Project code: github.com/furkancmc/teknofest-kadim-kamu-evrak-ajani (
QWEN_VL_ocr/) - Sibling adapters:
kadim-analiz-lora,kadim-yazi-lora
Model details
| Base model | Qwen/Qwen2.5-VL-7B-Instruct |
| Method | LoRA in bf16; the vision encoder is frozen and adapters are added to the language-model layers only |
| LoRA rank / alpha / dropout | 16 / 32 / 0.05 |
| Language | Turkish |
| License | MIT (the base model is Apache-2.0) |
Note: adapter_config.json stores the training-time local path of the base model. Load the base from the Hub as shown below; PEFT uses the base you pass in.
Intended use
Turning scanned or photographed Turkish petitions and official letters into plain text, as the first stage of the KADİM pipeline (OCR → analysis → legislation retrieval → officer decision → letter draft).
How to use
import torch
from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
from peft import PeftModel
from PIL import Image
base_id = "Qwen/Qwen2.5-VL-7B-Instruct"
adapter_id = "furkancmc/kadim-ocr-lora"
processor = AutoProcessor.from_pretrained(base_id)
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
base_id, torch_dtype=torch.bfloat16, device_map="auto"
)
model = PeftModel.from_pretrained(model, adapter_id)
image = Image.open("document.png").convert("RGB")
messages = [{
"role": "user",
"content": [
{"type": "image"},
{"type": "text", "text": "Bu belgedeki metni olduğu gibi yaz."}, # use the prompt from the training notebook
],
}]
prompt = processor.apply_chat_template(messages, add_generation_prompt=True)
inputs = processor(text=[prompt], images=[image], return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=2048, do_sample=False)
print(processor.batch_decode(out[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0])
For the exact instruction text used in training and evaluation, see QWEN_VL_ocr/qwen_ocr_finetune_lora.ipynb. In the full system the adapter is served with vLLM next to the Qwen2.5-VL base.
Training data
Dataset: furkancmc/kadim-ocr-data (train, validation and test splits).
1,000 synthetic document images (800 train / 100 validation / 100 test). The text comes from the open erdem-erdem/Turkish-Law-Documents-700k-clustered corpus of public court decisions (Yargıtay and Danıştay). generate_dataset_1000.py re-typesets each text as a letterhead page and degrades it to simulate scans, in four equal groups of 250:
| Group | Scan quality |
|---|---|
| A | Clean print, no degradation |
| B | Slight blur, small contrast shift |
| C | Clear blur, reduced contrast, noise |
| D | Low resolution, heavy noise, skew |
The images are synthetic training pages, not scans of real official documents, and contain no personal data of real citizens.
Evaluation
Test set: 100 document images, 21,571 Turkish characters. Base model and adapter were evaluated on the same set under the same conditions.
| Model | Character error rate (CER) ↓ | Turkish-character accuracy ↑ |
|---|---|---|
| Qwen2.5-VL-7B-Instruct (base) | 0.4283 | 78.55% |
| + this adapter | 0.1076 | 85.90% |
CER drops by about 75% (roughly 4×). Notebooks: qwen_ocr_baseline_test.ipynb (base) and qwen_ocr_finetune_lora.ipynb (adapter).
Limitations
- Trained and tested on synthetic degradations of typeset text; real scans, handwriting, stamps and unusual layouts are not covered by the evaluation.
- Turkish-character accuracy is still 85.9%, so OCR output should be treated as noisy input to the downstream analysis step.
- Long multi-page documents should be processed page by page.
Citation
@misc{kadim2026,
title = {KADİM: Kamu Dilekçe ve İnceleme Mekanizması},
author = {Camcıoğlu, Furkan},
year = {2026},
url = {https://github.com/furkancmc/teknofest-kadim-kamu-evrak-ajani}
}
- Downloads last month
- 27
Model tree for furkancmc/kadim-ocr-lora
Base model
Qwen/Qwen2.5-VL-7B-Instruct