Skip to main content
Reward rubrics leverage LLMs to evaluate outputs using natural language criteria. They use the @osmosis_rubric decorator and delegate scoring to a language model based on a rubric description.

Basic Example

File: reward_rubric/reward_rubric_openai.py

Function Signature

The evaluate_rubric Function

The evaluate_rubric helper function handles the LLM evaluation:

Parameters

Supported Providers

OpenAI

Anthropic

For additional providers (Google Gemini, xAI Grok, OpenRouter, Cerebras), see the API Reference.

Writing Effective Rubrics

Be Specific

Include Scoring Guidelines

Provide Examples

Advanced Patterns

Multi-Aspect Evaluation

Context-Aware Rubric

Getting Detailed Feedback

Error Handling

Always handle errors gracefully:

Best Practices

1. Keep API Keys Secure

2. Choose Appropriate Models

3. Cache API Calls When Possible

4. Set Appropriate Score Ranges

Testing Locally

Test your rubrics before deployment:

Next Steps

Setup Guide

Complete setup walkthrough

Best Practices

Tips and troubleshooting

Python SDK

Full API reference

Example Repo

See complete examples