Downloads · 30 days
13
5% of all-time downloads
bhaskar1707/qwen3.5-latex-ocr-finetune
qwen3.5-latex-ocr-finetune is a image-to-text model from bhaskar1707. Use it when you need a caption or text from an image. The card lists the license as apache-2.0.
Downloads · 30 days
13
5% of all-time downloads
All-time downloads
263
Public
Parameters
873M
1.8 GB on disk
Likes
1
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 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.
⚠️ A full-scale version trained on the complete 68.7k-row
unsloth/LaTeX_OCRdataset is available atqwen3.5-latex-ocr-finetune-v2.
SFTTrainer)unsloth/LaTeX_OCR — handwritten/printed math formula images paired with LaTeX transcriptions| Setting | Value |
|---|---|
| LoRA rank (r) | 16 |
| LoRA alpha | 16 |
| Learning rate | 2e-4 |
| Batch size (per device) | 2 |
| Gradient accumulation | 4 |
| Max steps | 30 |
| Optimizer | adamw_8bit |
| Hardware | Colab T4 |
| Training time | 5.35 min |
| Peak GPU memory | 2.78 GB |

Evaluated on a held-out split of 30 samples (not seen during training) from the same dataset, using Character Error Rate (CER), exact-match accuracy, and BLEU.
| Metric | Before fine-tuning | After fine-tuning |
|---|---|---|
| Mean CER ↓ | 0.150 | 0.110 |
| Exact match accuracy ↑ | 0.000 | 0.200 |
| Mean BLEU ↑ | 0.855 | 0.883 |

from transformers import AutoModelForImageTextToText, AutoProcessor
from PIL import Image
import torch
model_id = "bhaskar1707/qwen3.5-latex-ocr-finetune"
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", 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