AI Pulse by Inblix

Hugging Face TRL now trains vision models with DPO on 83K-row datasets

Hugging Face Blog · Jul 10, 2024 · 2 min read · Read original article →

Curated by the Inblix editorial team


Featured image for article: Hugging Face TRL now trains vision models with DPO on 83K-row datasets

Hugging Face’s TRL library just got a capability upgrade that quietly matters more than most model releases: direct preference optimization now works on vision language models, not just text. The team walked through the mechanics using the openbmb/RLAIF-V-Dataset, which packs over 83,000 annotated preference pairs. Each row pairs a question about an image with two candidate answers — one chosen, one rejected — and the model learns to favor the chosen response.

The example they use is telling. For the question “How many families?” the rejected answer says the image provides no information about families. The chosen answer claims the image shows “a Union Organization table setup with 18,000 families.” Here’s the kicker: that chosen answer is still wrong. The dataset explicitly notes that chosen responses aren’t necessarily correct — they’re just less wrong than the rejected ones. That’s a much more honest framing of preference optimization than the typical “good vs bad” narrative, and it reflects how RLHF-style training actually works in practice: you’re ranking relative quality, not certifying truth.

On the technical side, the formatting pipeline matters if you’re planning to replicate this. You need to structure each example as a conversation between a user and an assistant, apply the processor’s chat template, and resize images to fit within the model’s maximum edge size to avoid out-of-memory errors. The team also flagged a subtle gotcha: cast the image feature to decode=True so you’re not storing raw bytes. They trained Idefics2-8b for the demo, but the implementation supports Llava 1.5 and PaliGemma too.

What’s genuinely new here isn’t DPO itself — that’s been around since 2023 — it’s that TRL is making it accessible for multimodal models without requiring you to hand-roll the data pipeline. If you’ve got an 80GB GPU, the post walks through the memory math to tell you whether Idefics2-8b will fit. The broader implication is that preference tuning for VLMs is moving from research code to a standard library call, which is the same trajectory text models followed. Expect more visually grounded assistants that are tuned for helpfulness rather than just next-token prediction.

💡 Key Takeaways

  1. TRL's DPO implementation now supports vision language models including Idefics2-8b, Llava 1.5, and PaliGemma.
  2. The openbmb/RLAIF-V-Dataset contains over 83,000 preference pairs where chosen answers are not necessarily correct — just relatively better than rejected ones.
  3. Formatting requires applying a chat template, resizing images to the processor's maximum edge length, and casting image features with decode=True to avoid storing bytes.
  4. Preference optimization for VLMs is shifting from bespoke research code to a standard library feature, mirroring the trajectory text models followed.

Keep reading: See related articles below for more coverage on this topic.

Get smarter about AI

The sharpest AI news, curated daily. Delivered free to your inbox.

Learn more

Glossary terms

← Back to all articles