Skip to main content
This guide covers advanced features of the ONNX Runtime GenAI C++ API, including multi-turn conversations, custom generation parameters, and multimodal input processing.

Multi-Turn Chat

The chat example demonstrates continuous conversation with context preservation:

Key Features

Context Preservation

The chat example maintains conversation context across turns:

Rewind Functionality

Control conversation history with the rewind feature:

Signal Handling

Gracefully terminate generation with signal handlers:

Custom Generation Parameters

Fine-tune generation behavior with custom parameters:

Parameter Descriptions

  • max_length: Maximum number of tokens to generate
  • temperature: Controls randomness (higher = more random)
  • top_p: Nucleus sampling threshold
  • top_k: Number of highest probability tokens to consider
  • repetition_penalty: Penalizes repeated tokens
  • num_beams: Number of beams for beam search

Multimodal Processing

Process images and audio alongside text input:

Constrained Decoding with Guidance

Use JSON schema or LARK grammar for structured output:

Performance Monitoring

Track generation performance with timing utilities:

Building Advanced Examples

Build multiple examples at once:

Running Advanced Examples

Multi-Turn Chat

Multimodal Processing

Tool Calling with JSON Schema

Next Steps