class Llamero::BaseGrammar
- Llamero::BaseGrammar
- Reference
- Object
Overview
A base class for grammars. Grammars are the expected responses syntax from the LLM. Using a grammar can significantly help improve the consistency of the structured responses while saving on context window tokens.
To create a grammar, inherit from this class and define properties on the child class. All properties will be automatically converted to a grammar syntax.
Any properties that use a non-primitive type must inherit from Llamero::BaseGrammar
as well.
This class defines the necessary methods for rendering a JSON serializable object into a grammar syntax that can be provided to the LLM at run-time or output to a file.
Included Modules
- JSON::Serializable
Direct Known Subclasses
Defined in:
grammars/base_grammar.crConstructors
Class Method Summary
Instance Method Summary
-
#to_grammar_file(is_root_object : Bool = true) : IO
Creates the grammar in a format that can be saved into a
.gbnf
file
Constructor Detail
Class Method Detail
Instance Method Detail
Creates the grammar in a format that can be saved into a .gbnf
file