Table of Contents

Constructor Grammar

Namespace
LMKit.TextGeneration.Sampling
Assembly
LM-Kit.NET.dll

Grammar(string, string)

Initializes a new instance of the Grammar class by parsing a string containing GGML BNF (Backus-Naur Form) grammar definitions. For more information on GGML BNF, see the GGML BNF documentation.

public Grammar(string gbnf, string startRule = "root")

Parameters

gbnf string

The string containing the grammar definitions in GGML BNF format.

startRule string

The name of the start rule for this grammar. Defaults to "root".

Exceptions

GrammarParsingException

Thrown if the input string is malformed or cannot be parsed into a valid grammar.

Grammar(PredefinedGrammar)

Initializes a new instance of the Grammar class using a predefined grammar type.

public Grammar(Grammar.PredefinedGrammar type)

Parameters

type Grammar.PredefinedGrammar

The type of predefined grammar to create.

Exceptions

ArgumentException

Thrown if the specified type is not recognized.