LumiChats v1.2 7B - Vision-Language Model for LaTeX OCR
Vision-language model fine-tuned for converting handwritten mathematical formulas to LaTeX
🌟 Model Overview
LumiChats v1.2 7B is a specialized vision-language model built on Qwen2.5-VL-7B-Instruct, fine-tuned using LoRA for Image-to-LaTeX OCR. This model excels at converting handwritten mathematical formulas from images into properly formatted LaTeX code.
Primary Use Case: Mathematical OCR
- 📐 Handwritten Formula Recognition - Converts images of mathematical equations to LaTeX
- 🧮 Symbol Detection - Recognizes complex mathematical symbols (∫, ∂, β, ζ, etc.)
- ✍️ Handwriting Robustness - Handles variations in handwriting styles
- 🎯 High Accuracy - Domain-adapted for mathematical notation
- ⚡ Fast Inference - 4-bit quantized for efficient processing
Key Specifications
| Feature | Value |
|---|
| Base Model | Qwen2.5-VL-7B-Instruct |
| Parameters | ~7B (vision + language) |
| Training Method | LoRA (r=16, alpha=16) |
| Trainable Params | 51.5M (0.62% of total) |
| Quantization | 4-bit (bnb-4bit) |
| Dataset | unsloth/LaTeX_OCR (68,686 samples) |
| Training Time | 3.27 minutes (30 steps on Tesla T4) |
| Peak Memory | 0.674 GB for training |
| Task | Image-to-LaTeX conversion |
🏢 About LumiChats
LumiChats is a student-first AI platform that provides access to 39+ premium and open-source AI models at
₹69/day (pay-only-when-you-use pricing). Our mission is to democratize AI education and make powerful language models accessible to students, developers, and creators without expensive subscriptions.
Why LumiChats?
- ✅ Pay-Per-Day Pricing - Only ₹69 on days you use AI (vs ₹5,900/month for ChatGPT + Claude + Gemini subscriptions)
- ✅ 39+ AI Models - Switch between GPT-4, Claude, Gemini, Qwen, DeepSeek, Mistral instantly
- ✅ Study Mode - Page-by-page PDF learning, custom quizzes, note generation
- ✅ Memory Control - Selective context activation for focused learning
- ✅ 5M Tokens Daily - Generous usage limits for intensive study sessions
Average student cost: ₹690/month (10 active days) vs ₹5,900 for competitor subscriptions → 88% savings
🚀 Model Architecture
Base Model: Qwen2.5-VL-7B-Instruct
Built on Qwen2.5 Vision-Language architecture, combining:
- Vision Encoder - Processes images and extracts visual features
- Language Model - 7B parameter transformer for text generation
- Multimodal Fusion - Integrates visual and textual information
Core Capabilities:
- Multimodal understanding (image + text)
- Visual reasoning and pattern recognition
- Structured text generation (LaTeX, code, markdown)
- Instruction following for complex tasks
4-bit Quantization Impact:
- ✅ 70% memory reduction - Runs on GPUs with limited VRAM (T4, RTX 3060)
- ✅ Faster inference - Optimized kernels for 4-bit operations
- ✅ Minimal accuracy loss - Modern quantization preserves model quality
Fine-Tuning with LoRA
Method: LoRA (Low-Rank Adaptation) - Parameter-efficient fine-tuning
1LoRA Configuration:
2- r (rank): 16
3- lora_alpha: 16
4- lora_dropout: 0.0
5- bias: "none"
6- finetune_vision_layers: True
7- finetune_language_layers: True
8- finetune_attention_modules: True
9- finetune_mlp_modules: True
10- trainable_parameters: 51,521,536 / 8,343,688,192 (0.62%)
Selective Component Fine-tuning:
- ✅ Vision Layers - Adapts image feature extraction for mathematical notation
- ✅ Language Layers - Optimizes LaTeX generation and formatting
- ✅ Attention Modules - Improves symbol-to-text mapping
- ✅ MLP Layers - Enhances complex pattern recognition
- 68,686 samples of handwritten formulas with LaTeX ground truth
- Conversational format: User (image + instruction) → Assistant (LaTeX output)
- Covers diverse mathematical notation: integrals, derivatives, fractions, Greek symbols
Training Configuration:
1- per_device_train_batch_size: 2
2- gradient_accumulation_steps: 4 (effective batch size = 8)
3- max_steps: 30
4- learning_rate: 2e-4
5- optimizer: adamw_8bit
6- lr_scheduler: linear decay
7- warmup_steps: 5
📊 Performance: Base vs Fine-tuned
Example: Handwritten Formula OCR
Input Image: Complex mathematical formula with integrals, derivatives, Greek symbols
| Model | Output LaTeX | Accuracy |
|---|
| Base Model (before fine-tuning) | H^\prime = \beta N \int d\lambda \left\{ \frac{1}{2B^2N^{2}} \partial_\lambda\zeta^\dagger\partial_\lambda\zeta + V(\lambda)\zeta^\dagger\zeta \right\} | ❌ Incorrect symbols |
| Fine-tuned Model | H ^ { \prime } = \beta N \int d \lambda \left\{ { \frac { 1 } { 2 \beta ^ { 2 } P N ^ { 2 } } } \partial _ { s } \zeta ^ { \dagger } \partial _ { s } \zeta + V ( \lambda ) \zeta ^ { \dagger } \zeta \right\} | ✅ Correct formatting |
Key Improvements:
- ✅ Corrected denominator:
2B^2N^{2} → 2 \beta ^ { 2 } P N ^ { 2 }
- ✅ Fixed partial derivatives:
\partial_\lambda → \partial _ { s }
- ✅ Better spacing and LaTeX style adherence
- ✅ Proper delimiter usage (
\left\{, \right\})
Why Fine-tuning Matters
Domain Adaptation: The base Qwen2.5-VL model is general-purpose, but lacks specialized knowledge of:
- Mathematical handwriting variations
- LaTeX syntax conventions
- Symbol-to-code mapping for complex formulas
After fine-tuning on 68K LaTeX OCR examples, the model learns:
- Precise character recognition in mathematical context
- Correct LaTeX formatting rules
- Robust handling of handwriting ambiguities
Efficiency Gains (Unsloth + LoRA)
| Metric | Full Fine-tuning | LoRA Fine-tuning | Savings |
|---|
| Trainable Parameters | 8.3B (100%) | 51.5M (0.62%) | 99.4% reduction |
| Training Memory | ~12-14 GB | 0.674 GB | 95% reduction |
| Training Time | Hours-Days | 3.27 minutes | 100x+ faster |
| Storage | Full model (~28 GB) | LoRA adapters (~200 MB) | 99% smaller |
💻 Usage
Quick Start (Transformers + Unsloth)
1from unsloth import FastVisionModel
2import torch
3
4model_name = "lumichats/lumichats-v1.2-7b-bnb-4bit"
5
6# Load model
7model, tokenizer = FastVisionModel.from_pretrained(
8 model_name,
9 load_in_4bit=True,
10 use_gradient_checkpointing="unsloth",
11)
12
13# Prepare for inference
14FastVisionModel.for_inference(model)
15
16# Load image
17from PIL import Image
18image = Image.open("handwritten_formula.png")
19
20# Create prompt
21instruction = "Write the LaTeX representation for this image."
22messages = [
23 {"role": "user", "content": [
24 {"type": "image"},
25 {"type": "text", "text": instruction}
26 ]}
27]
28
29# Tokenize
30input_text = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
31inputs = tokenizer(
32 image,
33 input_text,
34 add_special_tokens=False,
35 return_tensors="pt",
36).to("cuda")
37
38# Generate LaTeX
39outputs = model.generate(
40 **inputs,
41 max_new_tokens=128,
42 temperature=1.5,
43 min_p=0.1,
44 use_cache=True
45)
46
47latex_output = tokenizer.decode(outputs[0], skip_special_tokens=True)
48print(latex_output)
Using Standard Transformers
1from transformers import AutoModelForVision2Seq, AutoProcessor
2from PIL import Image
3
4model_name = "lumichats/lumichats-v1.2-7b-bnb-4bit"
5
6# Load model and processor
7processor = AutoProcessor.from_pretrained(model_name)
8model = AutoModelForVision2Seq.from_pretrained(
9 model_name,
10 device_map="auto",
11 load_in_4bit=True,
12 trust_remote_code=True
13)
14
15# Prepare inputs
16image = Image.open("math_formula.png")
17messages = [
18 {"role": "user", "content": [
19 {"type": "image"},
20 {"type": "text", "text": "Write the LaTeX representation for this image."}
21 ]}
22]
23
24text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
25inputs = processor(images=image, text=text, return_tensors="pt").to("cuda")
26
27# Generate
28output = model.generate(**inputs, max_new_tokens=256)
29latex = processor.decode(output[0], skip_special_tokens=True)
30print(latex)
🎯 Generation Parameters
Recommended Settings for LaTeX OCR
1model.generate(
2 **inputs,
3 max_new_tokens=128, # Limit output length
4 temperature=1.5, # Balanced creativity/accuracy
5 min_p=0.1, # Filter low-probability tokens
6 use_cache=True, # Faster inference
7 do_sample=True # Enable sampling
8)
Parameter Explanations:
- temperature=1.5: Allows flexibility for handwriting variations while maintaining accuracy
- min_p=0.1: Ensures only high-probability tokens (prevents hallucinations)
- max_new_tokens=128: Sufficient for most mathematical formulas
- use_cache=True: Speeds up autoregressive generation
⚙️ Technical Specifications
Model Configuration
1Base Model: Qwen2.5-VL-7B-Instruct
2Architecture: Vision-Language Transformer
3
4Vision Encoder:
5 - Processes images of handwritten math
6 - Extracts visual features for symbols
7
8Language Model:
9 - Parameters: ~7B
10 - Generates LaTeX code
11 - Context: Up to 2048 tokens for formulas
12
13Quantization:
14 - Method: bitsandbytes 4-bit NF4
15 - Compute dtype: bfloat16 (if supported)
16
17LoRA Adapters:
18 - Rank: 16
19 - Alpha: 16
20 - Trainable: 51.5M parameters (0.62%)
System Requirements
| Configuration | Minimum | Recommended |
|---|
| GPU VRAM | 6GB (4-bit) | 8GB+ |
| RAM | 8GB | 16GB+ |
| Storage | 10GB | 20GB |
| CUDA | 11.8+ | 12.1+ |
| Python | 3.8+ | 3.10+ |
Supported Formats
- ✅ Safetensors (recommended for HuggingFace)
- ✅ GGUF (Q4_K_M for llama.cpp - CPU inference)
- ✅ LoRA Adapters (merge with base model)
- ✅ FP16 merged (for vLLM deployment)
📦 Installation
1# Core dependencies
2pip install torch transformers accelerate bitsandbytes
3
4# For Unsloth (2x faster training/inference)
5pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
6
7# For image processing
8pip install pillow
🔧 Advanced: Fine-tuning on Your Data
Want to adapt this model for other OCR tasks (e.g., printed text, diagrams)?
1from unsloth import FastVisionModel
2from trl import SFTTrainer, SFTConfig
3from unsloth.trainer import UnslothVisionDataCollator
4
5# Load base model
6model, tokenizer = FastVisionModel.from_pretrained(
7 "lumichats/lumichats-v1.2-7b-bnb-4bit",
8 load_in_4bit=True,
9)
10
11# Apply LoRA for further fine-tuning
12model = FastVisionModel.get_peft_model(
13 model,
14 finetune_vision_layers=True,
15 finetune_language_layers=True,
16 finetune_attention_modules=True,
17 finetune_mlp_modules=True,
18 r=16,
19 lora_alpha=16,
20 lora_dropout=0,
21 bias="none",
22)
23
24# Prepare your dataset in messages format
25# [{"messages": [{"role": "user", "content": [...]}, {"role": "assistant", "content": [...]}]}]
26
27# Train
28trainer = SFTTrainer(
29 model=model,
30 tokenizer=tokenizer,
31 train_dataset=your_dataset,
32 data_collator=UnslothVisionDataCollator(model, tokenizer),
33 args=SFTConfig(
34 per_device_train_batch_size=2,
35 gradient_accumulation_steps=4,
36 warmup_steps=5,
37 max_steps=100,
38 learning_rate=2e-4,
39 optim="adamw_8bit",
40 output_dir="outputs",
41 dataset_kwargs={"skip_prepare_dataset": True},
42 ),
43)
44
45trainer.train()
📚 Cite This Model
1@misc{lumichats_v1.2_2026,
2 title={LumiChats v1.2: Fine-tuned Qwen2.5-7B for Educational AI},
3 author={LumiChats Team},
4 year={2026},
5 publisher={HuggingFace},
6 howpublished={\url{https://huggingface.co/lumichats/lumichats-v1.2-7b-bnb-4bit}},
7}
⚖️ License & Usage
Model License
This model is released under the Apache 2.0 License, allowing:
- ✅ Commercial use
- ✅ Modification and distribution
- ✅ Private use
- ✅ Patent use
Base Model License
Inherits from Qwen2.5 (Apache 2.0) - see
Qwen License
Ethical Use Guidelines
Please use this model responsibly:
- ❌ Do not generate harmful, illegal, or discriminatory content
- ❌ Do not impersonate real individuals
- ✅ Verify factual outputs (models can hallucinate)
- ✅ Respect user privacy and data protection laws
Built with ❤️ for students, developers, and creators worldwide
Only ₹69/day • No subscriptions • All AI models included