UForm-Gen2-dpo is a small generative vision-language model alined for Image Captioning and Visual Question Answering
on preference datasets VLFeedback and LLaVA-Human-Preference-10K using Direct Preference Optimization (DPO).
The model took less than one day to train on a DGX-H100 with 8x H100 GPUs.
Thanks to
Nebius.ai for providing the compute 🤗
The generative model can be used to caption images, answer questions about them. Also it is suitable for a multimodal chat.
1from transformers import AutoModel, AutoProcessor
2model = AutoModel.from_pretrained("unum-cloud/uform-gen2-dpo", trust_remote_code=True)
3processor = AutoProcessor.from_pretrained("unum-cloud/uform-gen2-dpo", trust_remote_code=True)
4prompt = "Question or Instruction"
5image = Image.open("image.jpg")
6inputs = processor(text=[prompt], images=[image], return_tensors="pt")
7with torch.inference_mode():
8 output = model.generate(
9 **inputs,
10 do_sample=False,
11 use_cache=True,
12 max_new_tokens=256,
13 eos_token_id=151645,
14 pad_token_id=processor.tokenizer.pad_token_id
15 )
16prompt_len = inputs["input_ids"].shape[1]
17decoded_text = processor.batch_decode(output[:, prompt_len:])[0]
You can check examples of different prompts in our demo space.
perception reasoning OCR artwork celebrity code_reasoning color commonsense_reasoning count existence landmark numerical_calculation position posters scene text_translation