SingleTurnEnv
Environment for single-turn tasks where the model generates a single response to a prompt.
Overview
SingleTurnEnv is the simplest environment type, designed for Q&A tasks where:
- The model receives a prompt and generates a single response
- No multi-turn interaction is needed
- Scoring is based on the single response
This class inherits from MultiTurnEnv with max_turns=1 and disables env_response().
Inheritance
Constructor
Accepts all parameters from Environment constructor. The max_turns parameter is automatically set to 1.
Key Differences from MultiTurnEnv
max_turns is fixed at 1 (cannot be overridden)
env_response() raises NotImplementedError if called
- Rollout completes after a single model response
Methods
env_response
This method raises NotImplementedError for SingleTurnEnv. It is not used in single-turn scenarios.
render_completion
Renders the final completion from the trajectory. Inherited from MultiTurnEnv.
Example Usage
With Multiple Metrics
With Few-Shot Examples
Common Patterns
Basic Q&A
Use SingleTurnEnv directly with a dataset and rubric:
Custom Scoring
Define reward functions that accept fields from your dataset:
Multiple Rollouts per Example
Generate multiple responses per question for majority voting:
When to Use
Use SingleTurnEnv for:
- Question answering
- Text classification
- Summarization
- Translation
- Any task requiring a single model response
For tasks requiring multiple turns of interaction, use MultiTurnEnv instead.
See Also