Live data from Hacker News

Run structured extraction on documents/images locally with Ollama and Pydantic

github.com

21–30 of 32 posts

Re: Run structured extraction on documents/images locally with Ollama and Pydantic

#21

I've used "structured output" (with supplied schema) on Google and openai, and function calling / tool use on those, anthropic and others- and afaict they are functionally the same (if you force a specific function / schema). Has someone had a different experience?

The model might not use the tools every completion, depending on your setup.

Re: Run structured extraction on documents/images locally with Ollama and Pydantic

#22
Super cool! We at BAML had been thinking about doing something like this for our ecosystem as well - we’d love to add BAML models to this repo!

If you haven’t heard of us, we provide a language and runtime that enable defining your schemas in a simpler syntax, and allow usage with _any_ model, not just those that implement tool calling or json mode, by by relying on schema-aligned parsing. Check it out! https://github.com/BoundaryML/baml

Re: Run structured extraction on documents/images locally with Ollama and Pydantic

#25
post #19

Earlier quoted context omitted.

I meant between "structured output" and "function calling". Afaict one is outputting according to a schema and the other is outputting according to a schema... which will be used as the parameters to a function. But they seem to be considered disparate concepts. So I'm trying to understand if there's some additional nuance I'm missing.

With function calls the model may or may not output something that matches the schema, with structured output the schema is enforced at the logit level.

At least in the case of openai, you can set "strict" to "true" and function calling / tool use must / is enforced to follow the schema too.

Re: Run structured extraction on documents/images locally with Ollama and Pydantic

#26

Earlier quoted context omitted.

I meant between "structured output" and "function calling". Afaict one is outputting according to a schema and the other is outputting according to a schema... which will be used as the parameters to a function. But they seem to be considered disparate concepts. So I'm trying to understand if there's some additional nuance I'm missing.

Ah ok, I misunderstood. As far as I've seen, structured outputs is essentially "json-mode" with some constraints (i.e. guided decoding over a known schema) - so the model effectively emits valid JSON that conforms to the schema. In function calling, the model is asked to emit "code" that conforms to some function parameter spec. You could use json-mode for function-calling, but probably not the other way around. I've…

I don't understand the difference based on your explanation (or the significance of "code") and have used function calling for outputting json according to a schema.

Re: Run structured extraction on documents/images locally with Ollama and Pydantic

#28
post #23

What are the most promising ways to extract information from picture like this, if the domain has strict time constraints? What's the second best way that is still fast?

You can always distill VLMs into much smaller / faster models that’s specific to your domain or use-case.

What’s the use-case and what kind of latency do you require?

Re: Run structured extraction on documents/images locally with Ollama and Pydantic

#30

Super cool! We at BAML had been thinking about doing something like this for our ecosystem as well - we’d love to add BAML models to this repo! If you haven’t heard of us, we provide a language and runtime that enable defining your schemas in a simpler syntax, and allow usage with _any_ model, not just those that implement tool calling or json mode, by by relying on schema-aligned parsing. Check it out! https://githu…

Would love to chat! reach out scott@vlm.run
Post reply on HN