Ollama Now Officially Supports Structured Outputs

The video introduces a new feature in the Ollama platform that allows users to obtain structured outputs from the Llama model, ensuring consistency and reliability in the data returned by defining specific output formats. The presenter demonstrates the ease of using this feature through examples and highlights its applicability across different data types, including text and images, making it a valuable tool for developers.

In the recent video, the presenter discusses a new feature in the Ollama platform that allows for structured outputs from the Llama model. This feature enables users to define specific output formats using adjacent schemas, which ensures that the data returned by the model adheres to a predetermined structure. Previously, users could only request outputs in formats like JSON, but the results were often unpredictable and varied with each request. The introduction of structured outputs aims to provide more consistency and reliability in the data returned.

The presenter demonstrates the previous method of obtaining a list of cities in JSON format, highlighting the inconsistency in the output. When the model was queried multiple times, the results varied significantly, making it difficult to rely on the data. With the new structured output feature, users can now specify the desired format, leading to more accurate and predictable results. The example provided shows a query about Wales, where the model returns structured information about the capital and languages spoken, formatted correctly as defined by the user.

Additionally, the video showcases how to utilize the Ollama library and make requests via the command line using curl. The presenter runs a query to retrieve details about Wales, demonstrating how the output can be piped into JQ for better readability. This structured output feature is particularly beneficial for users who need consistent data formats for further processing or integration into applications.

The presenter also highlights the availability of the Ollama library in Python and JavaScript, allowing developers to easily implement structured outputs in their projects. A more complex example is provided, where a list of cities is requested using a specific schema. The comparison with OpenAI’s previous methods illustrates the simplicity and efficiency of using Ollama for structured outputs, as it eliminates the need for additional clients and complex setups.

Finally, the video emphasizes that the structured output feature is not limited to text inputs; it can also be applied to image queries, expanding its utility across different types of data. The presenter encourages viewers to explore this new feature and experiment with various queries, highlighting its potential for diverse applications. Overall, the introduction of structured outputs in Ollama represents a significant advancement for users working with open models on their machines.