Skip to content

v4.1.0: Structured Outputs with Ollama

Latest
Compare
Choose a tag to compare
@ccreutzi ccreutzi released this 13 Dec 12:30
· 5 commits to main since this release

Ensure output format using structured outputs with Ollama

You can now use structured output to generate output using ollamaChat objects.

In LLMs with MATLAB, you can specify the structure of the output in two different ways.

  • Specify a valid JSON Schema directly.
  • Specify an example structure array that adheres to the required output format. The software automatically generates the corresponding JSON Schema and provides this to the LLM. Then, the software automatically converts the output of the LLM back into a structure array.

To do this, set the ReponseFormat name-value argument of ollamaChat or generate to one of these options.

  • A string scalar containing a valid JSON Schema.
  • A structure array containing an example that adheres to the required format, for example:
    ResponseFormat=struct("Name","Rudolph","NoseColor",[255 0 0])

For more information on structured output in Ollama™, see https://ollama.com/blog/structured-outputs.

Full Changelog: v4.0.0...v4.1.0