LlamaGrammar

A GBNF grammar constraining generation (llama.cpp llama_sampler_init_grammar).

Build one with gbnf, jsonSchema or json. GBNF text is validated by llama.cpp when generation starts; a grammar that does not parse fails the generation with com.donfuldauer.kggml.core.InvalidInputException.

Types

Link copied to clipboard
object Companion

Constants and factory functions of LlamaGrammar.

Properties

Link copied to clipboard

the grammar text.

Link copied to clipboard

the start symbol.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Grammars are equal when their gbnf text and root symbol are equal.

Link copied to clipboard
open override fun hashCode(): Int

Hash of gbnf and root, consistent with equals.

Link copied to clipboard
open override fun toString(): String

The root symbol and the grammar length, without the grammar text.