Class Grammar
- Namespace
- LMKit.TextGeneration.Sampling
- Assembly
- LM-Kit.NET.dll
Represents a grammar class used in text generation models to define and manage grammar rules. This class provides functionalities for creating grammars, managing rules, and controlling token sampling.
public sealed class Grammar : IDisposable
- Inheritance
-
Grammar
- Implements
- Inherited Members
Constructors
- Grammar(PredefinedGrammar)
Initializes a new instance of the Grammar class using a predefined grammar type.
- 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.
Methods
- CreateJsonGrammarFromFields(IEnumerable<string>, IEnumerable<Type>)
Creates a new instance of the Grammar class based on a collection of JSON field names and their corresponding types.
- CreateJsonGrammarFromJsonScheme(string)
Creates a new instance of the Grammar class based on a given JSON schema.
- CreateJsonGrammarFromTextFields(IEnumerable<string>)
Creates a new instance of the Grammar class based on a collection of JSON text field names.
- Dispose()
Disposes of the Grammar instance and releases resources.