Downloads · 30 days
29
13% of all-time downloads
bhaskar1707/qwen3.5-latex-ocr-finetune-v2
qwen3.5-latex-ocr-finetune-v2 is a image-to-text model from bhaskar1707. Use it when you need a caption or text from an image. It is set up for transformers. The card lists the license as apache-2.0.
This is the full-scale successor to bhaskar1707/qwen3.5-latex-ocr-finetune, which was trained on a 30-step demo subset purely to validate the fine-tuning pipeline. This v2 model is trained on the complete unsloth/LaTe…
Downloads · 30 days
29
13% of all-time downloads
All-time downloads
219
Public
Parameters
873M
1.8 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.7 GB · 99%
How the weights are stored.
BF16873M · 100%
From the Hugging Face model README
This is the full-scale successor to bhaskar1707/qwen3.5-latex-ocr-finetune, which was trained on a 30-step demo subset purely to validate the fine-tuning pipeline. This v2 model is trained on the complete unsloth/LaTeX_OCR dataset with a proper train/validation/test split, giving a much more reliable estimate of real-world performance.
This model is a fine-tuned version of unsloth/Qwen3.5-0.8B, a vision-language model, adapted to convert images of handwritten/printed math formulas into LaTeX code.
Fine-tuning was performed using Unsloth with LoRA (parameter-efficient fine-tuning) on the unsloth/LaTeX_OCR dataset.
SFTTrainer)unsloth/LaTeX_OCR — full dataset (handwritten/printed math formula images paired with LaTeX transcriptions)bhaskar1707/qwen3.5-latex-ocr-finetune (30-step demo run, small subset)| Split | Samples |
|---|---|
| Train | 68,286 |
| Validation | 200 |
| Test | 200 |

| Setting | Value |
|---|---|
| LoRA rank (r) | 16 |
| LoRA alpha | 16 |
| Learning rate | 2e-4 |
| Batch size (per device) | 2 |
| Gradient accumulation | 4 |
| Epochs / Max steps | 1 epoch (max_steps=-1) |
| Optimizer | adamw_8bit |
| Hardware | Colab T4 |
| Training time | ~6 hours |
| Peak GPU memory | 3.52 GB |

Full per-step logs are available in training_loss_history.csv and validation_loss_history.csv.
Evaluated on a held-out test split of 200 samples (not seen during training), using Character Error Rate (CER), exact-match accuracy, and BLEU.
| Metric | Before fine-tuning | After fine-tuning |
|---|---|---|
| Mean CER ↓ | 0.126 | 0.043 |
| Exact match accuracy ↑ | 0.000 | 0.535 |
| Mean BLEU ↑ | 0.822 | 0.926 |

Full numeric results: metrics.json, before_after_comparison.csv.
A sample of qualitative before/after transcription examples (image → predicted LaTeX) is available in qualitative_before_after_examples.csv.
from transformers import AutoModelForImageTextToText, AutoProcessor
from PIL import Image
import torch
model_id = "bhaskar1707/qwen3.5-latex-ocr-finetune-v2"
model = AutoModelForImageTextToText.from_pretrained(model_id, torch_dtype=torch.float16, trust_remote_code=True).to("cuda")
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
image = Image.open("your_formula_image.png").convert("RGB")
instruction = "Write the LaTeX representation for this image."
messages = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": instruction}]}]
input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
inputs = processor(image, input_text, add_special_tokens=False, return_tensors="pt").to("cuda")
output_ids = model.generate(**inputs, max_new_tokens=128, temperature=1.5, min_p=0.1)
latex = processor.batch_decode(output_ids[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0]
print(latex)
Or with Unsloth (faster load/inference, requires a CUDA GPU):
from unsloth import FastVisionModel
model, tokenizer = FastVisionModel.from_pretrained("bhaskar1707/qwen3.5-latex-ocr-finetune-v2", load_in_4bit=True)
FastVisionModel.for_inference(model)
LaTeX_OCR dataset distribution; handwriting styles or symbols far outside this distribution may transcribe less accurately.unsloth/LaTeX_OCRFine-tuned by Bhaskar Pal — GitHub · LinkedIn