AI and Deep Learning Community Question

Can I use Instructor to extract entities from multi-modal inputs like images?

Posted on 2025-01-05 • In AI and Deep Learning • By Deborah Hall

I have a use case where I need to extract text from invoices and receipts. Since GPT-4o supports vision, can I use Instructor to define a Pydantic schema for the invoice fields and have the model populate it directly from an image? I want to avoid the OCR-then-LLM pipeline and go straight from image to structured data.

3 Answers 11,916 Views

All answers to this question 3 Answers

Heather Walker Answered on 2025-01-06
Answered

Absolutely, and it’s a game-changer for document processing. You just pass the image URL or base64 data in the messages array as you normally would with the OpenAI SDK. Since the library patches the client, you still just add response_model=InvoiceSchema. The model looks at the image and fills out the Pydantic fields. I’ve used this for medical forms and it’s surprisingly accurate at catching table data that traditional OCR often messes up. The best part is that you can add validation logic to check if the extracted total amount equals the sum of the line items.

Justin Clark Answered on 2025-01-07
Answered

How does the validation retry logic work with vision—does it resend the entire image for every retry, and does that double the cost?

Deborah Hall Commented on 2025-01-08
Commented

Justin, it does resend the image because the model needs the context to fix its mistake. This can get expensive if your image is high-resolution. My tip is to downscale the image to the minimum required for legibility before sending. Also, keep your schema simple to minimize the chance of a retry being needed in the first place.

Amy Young Answered on 2025-01-09
Answered

Going from raw pixels to a validated Python object in one step feels like magic every time I run it.

Heather Walker Commented on 2025-01-10
Commented

It really does, Amy. It’s significantly faster to develop than the old Tesseract-based pipelines we used to build.

Write a Comment

Your email address will not be published. Required fields are marked (*)

Join the LearnersEra Community

Ask questions, share knowledge and learn from professionals across technology, project management and certification topics.

Change Country and Nearest City

Select your country and nearest city to see courses available in your region.