Get the latest tech news

Structured Outputs with Ollama


Ollama now supports structured outputs making it possible to constrain a model's output to a specific format defined by a JSON schema. The Ollama Python and JavaScript libraries have been updated to support structured outputs.

To extract structured data from text, define a schema to represent information. Use Pydantic (Python) or Zod (JavaScript) to define the schema for the response Add “return as JSON” to the prompt to help the model understand the request Set the temperature to 0 for more deterministic output Exposing logits for controlled generation Performance and accuracy improvements for structured outputs GPU acceleration for sampling Additional format support beyond JSON schema

Get the Android app

Or read this on Hacker News