Skip to main content
The 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

Defined in: ~/workspace/source/src/ort_genai.h:412

Methods

Create()

Create generator parameters for a model.
const OgaModel&
required
The model to create parameters for
Returns: 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
Throws: std::runtime_error if the option name is invalid or value is out of range

Common Search Options

Example

From ~/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)
Throws: std::runtime_error if guidance setup fails

Example

From ~/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
Returns: 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
Returns: 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.
Explore multiple hypotheses in parallel.
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:

Parameter Validation

The library validates parameters when creating the generator. Invalid values will throw exceptions:

See Also