idefics2-8b-ft-docvqa-lora is a fine-tuned version of the HuggingFaceM4/idefics2-8b model, specifically trained on the doc-vqa dataset published by Crédit Mutuel Arkéa. Optimized using the LoRA (Low-Rank Adaptation) method, this model was designed to enhance performance while reducing the complexity of fine-tuning.
During training, particular attention was given to linguistic balance, with a focus on french. The model was exposed to a predominantly french context, with a 70% likelihood of interacting with french questions/answers for a given image. It operates exclusively in bfloat16 precision, optimizing computational resources. The entire training process took 3 days on a single A100 40GB.
Thanks to its multilingual specialization and emphasis on french, this model excels in francophone environments, while also performing well in english. It is especially suited for tasks that require the analysis and understanding of complex documents, such as extracting information from forms, invoices, reports, and other text-based documents in a visual question-answering context.
Model Details
Model Description
Developed by: Loïc SOKOUDJOU SONAGU and Yoann SOLA
1import requests
2import torch
3from PIL import Image
4from io import BytesIO
56from transformers import AutoProcessor, AutoModelForVision2Seq
7from transformers.image_utils import load_image
8910device ="cuda"if torch.cuda.is_available()else"cpu"1112# Note that passing the image urls (instead of the actual pil images) to the processor is also possible13image = load_image("https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg")1415model_id ="cmarkea/idefics2-8b-ft-docvqa-lora"16processor = AutoProcessor.from_pretrained("HuggingFaceM4/idefics2-8b", do_image_splitting=False)17model = AutoModelForVision2Seq.from_pretrained(18 model_id,19 torch_dtype=torch.bfloat16,20).to(device)2122# Create inputs23messages =[24{25"role":"user",26"content":[27{"type":"image"},28{"type":"text","text":"What do we see in this image?"},29]30}31]3233prompt = processor.apply_chat_template(messages, add_generation_prompt=True)34inputs = processor(text=prompt, image=image, return_tensors="pt")35inputs ={k: v.to(device)for k, v in inputs.items()}363738# Generate39with torch.inference_mode():40 generated_ids = model.generate(**inputs, max_new_tokens=500)41 generated_texts = processor.batch_decode(generated_ids, skip_special_tokens=True)42print(generated_texts)43
Results
By following the LLM-as-Juries evaluation method, the following results were obtained using three judge models (GPT-4o, Gemini1.5 Pro and Claude 3.5-Sonnet). This metric was adapted to the VQA context, with clear criteria for each score (0 to 5) to ensure the highest possible precision in meeting expectations.
constellation
idefics2-8b-ft-docvqa-lora and paligemma-3b-ft-docvqa-896-lora demonstrate equivalent performance despite having different model sizes.