CanvaSachinthaka AbeywardanaTutorial
Training and Serving Multimodal LLMs in Production
Summary
Canva built a custom vision-language model to review hundreds of thousands of images daily against more than 30 content and quality criteria, replacing expensive third-party LLMs. The team fine-tuned a 4B model using QLoRA with rank-24 LoRA applied to all linear layers, focusing the loss exclusively on boolean response tokens. To serve structured JSON outputs with confidence scores, they enforced the JSON format and extracted a probability for each review check. They accelerated inference with speculative decoding, which verifies multiple tokens in a single forward pass by exploiting the predictable output structure. The custom model cut costs by 85%, halved the false negative rate without increasing false positives, and reduced p50 production latency by 15x.
Context
Canva needed to review hundreds of thousands of images daily against 30+ content and quality criteria. Using third-party LLMs became too expensive at scale, so they built a custom vision-language model to perform these checks more accurately and at lower cost.
Approach / What changed
Fine-tuned a 4B vision-language model (Qwen3.5) using QLoRA with rank-24 LoRA applied to all linear layers, loss masking focused on boolean response tokens, and speculative decoding that verifies multiple tokens in a single forward pass by exploiting the predictable JSON output structure.
Takeaways
Fine-tuning a small vision-language model with QLoRA reduced LLM costs by approximately 85% compared to using third-party hosted models for high-volume content review.
Focusing the loss exclusively on boolean response tokens (true/false) during a second training stage improved accuracy on the classification task without requiring the model to learn JSON formatting.
Speculative decoding that verifies multiple tokens in a single forward pass, combined with prefix caching and exact max_tokens, reduced p50 production latency by 15x.
FAQ
How did QLoRA help fit the model into GPU memory?
QLoRA stores the frozen base weights in 4-bit form, freeing enough GPU memory to increase batch size from 4 to 24. This allows fine-tuning a 4B model within a limited GPU memory budget.
How is the loss masked during training?
Loss is calculated only on the assistant's response tokens, not on the prompt or image tokens. In a second stage, loss is further focused exclusively on the boolean (true/false) positions, so formatting tokens no longer contribute to the loss.
How does speculative decoding accelerate inference?
Speculative decoding uses the predictable JSON output structure to verify many tokens in a single forward pass. The decoder masks only two tokens at each boolean slot, and temperature is set to 0.0 since there is no reason to sample for boolean classification.
Source and freshness
- Source
- canva.dev
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.