OgaGeneratorParams class configures how text generation is performed. It provides methods to set search options like temperature, top-p, max length, and other parameters that control the generation process.
Class Definition
~/workspace/source/src/ort_genai.h:412
Methods
Create()
Create generator parameters for a model.const OgaModel&
required
The model to create parameters for
std::unique_ptr<OgaGeneratorParams> - A unique pointer to the created parameters
Throws: std::runtime_error if parameter creation fails
Example
SetSearchOption()
Set a numeric search option for generation.const char*
required
The name of the search option
double
required
The value to set
std::runtime_error if the option name is invalid or value is out of range
Common Search Options
Example
~/workspace/source/src/ort_genai.h:30
SetSearchOptionBool()
Set a boolean search option.const char*
required
The name of the boolean search option
bool
required
The boolean value to set
Common Boolean Options
Example
SetGuidance()
Set guidance for constrained generation (e.g., JSON schema, function calling).const char*
required
The guidance type (e.g., “json”, “regex”)
const char*
required
The guidance data (e.g., JSON schema, regex pattern)
bool
Enable fast-forward tokens optimization (default: false)
std::runtime_error if guidance setup fails
Example
~/workspace/source/examples/c/src/model_qa.cpp:99
GetSearchNumber()
Get the current value of a numeric search option.const char*
required
The name of the search option
double - The current value of the option
Throws: std::runtime_error if the option name is invalid
Example
GetSearchBool()
Get the current value of a boolean search option.const char*
required
The name of the boolean search option
bool - The current value of the option
Throws: std::runtime_error if the option name is invalid
Example
Generation Strategies
Greedy Decoding (Default)
Simply select the most likely token at each step.Sampling
Randomly sample from the probability distribution.Beam Search
Explore multiple hypotheses in parallel.Diverse Beam Search
Generate diverse outputs using beam search.Complete Examples
Basic Configuration
From~/workspace/source/src/ort_genai.h:29:
Advanced Sampling Configuration
Constrained Generation with JSON Schema
From~/workspace/source/examples/c/src/model_qa.cpp:98:
Multi-Sequence Beam Search
Parameter Validation
The library validates parameters when creating the generator. Invalid values will throw exceptions:See Also
- OgaGenerator - Use parameters for text generation
- OgaModel - Create parameters from models
- Search Options Reference - Full list of available options