[PR #1606] [CLOSED] Added support for specifying an arbitrary GBNF compatible grammar #21166

Closed
opened 2026-04-19 15:28:56 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/1606
Author: @clevcode
Created: 12/19/2023
Status: Closed

Base: mainHead: main


📝 Commits (2)

  • 3399bbd Added support for specifying an arbitrary GBNF compatible grammar
  • 7992692 Merge branch 'jmorganca:main' into main

📊 Changes

4 files changed (+42 additions, -0 deletions)

View changed files

📝 api/types.go (+1 -0)
📝 docs/modelfile.md (+1 -0)
examples/grammar/Modelfile (+39 -0)
📝 llm/llama.go (+1 -0)

📄 Description

in the Modelfile, for models running on the llama.cpp backend

Note that this is basically just the same PR as the one submitted by SyrupThinker in September (#565), and that has been mentioned in issue #1507 and #808 since then.

There are plenty of users that would appreciate this feature, so I really hope that it can get merged.

It's great that support for JSON grammar specifically has been added, by setting the GBNF grammar in question when JSON format is requested, but providing the user with the ability to specify an arbitrary grammar opens up for a lot more possibilities than that

Pull request #830 adds support for specifying JSON schemas, which is yet another great convenience feature for a specific and common usecase, but by adding support for arbitrary GBNF grammar it would be possible to have any model outputting data in any type of format, including custom DSLs and text-based file formats in general

This is a tremendously useful thing to have when building various types of automation related applications, so I really hope that this can get merged to avoid having to maintain separate forks. Ollama is a great project, let's keep making it even better


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/1606 **Author:** [@clevcode](https://github.com/clevcode) **Created:** 12/19/2023 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`3399bbd`](https://github.com/ollama/ollama/commit/3399bbdb9b3967408eccff0fc653efc6fe306e57) Added support for specifying an arbitrary GBNF compatible grammar - [`7992692`](https://github.com/ollama/ollama/commit/7992692bdd3cc2d0030af753b725e9ecc70f2bb5) Merge branch 'jmorganca:main' into main ### 📊 Changes **4 files changed** (+42 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+1 -0) 📝 `docs/modelfile.md` (+1 -0) ➕ `examples/grammar/Modelfile` (+39 -0) 📝 `llm/llama.go` (+1 -0) </details> ### 📄 Description in the Modelfile, for models running on the llama.cpp backend Note that this is basically just the same PR as the one submitted by SyrupThinker in September (#565), and that has been mentioned in issue #1507 and #808 since then. There are plenty of users that would appreciate this feature, so I really hope that it can get merged. It's great that support for JSON grammar specifically has been added, by setting the GBNF grammar in question when JSON format is requested, but providing the user with the ability to specify an arbitrary grammar opens up for a lot more possibilities than that Pull request #830 adds support for specifying JSON schemas, which is yet another great convenience feature for a specific and common usecase, but by adding support for arbitrary GBNF grammar it would be possible to have any model outputting data in any type of format, including custom DSLs and text-based file formats in general This is a tremendously useful thing to have when building various types of automation related applications, so I really hope that this can get merged to avoid having to maintain separate forks. Ollama is a great project, let's keep making it even better --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 15:28:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#21166