Skip to main content
The OpenAI RFT adapter lets you reuse Eval Protocol evaluation tests as Python graders for OpenAI Reinforcement Fine-Tuning (RFT). Because your grading logic lives in an Eval Protocol @evaluation_test, you can reuse the exact same code as an OpenAI Python grader—making it easy to start with OpenAI RFT and later move to other Eval-Protocol supported training workflows (or vice versa) without rewriting your evals. For a minimal working example, clone the openai-rft-quickstart repository, which contains the example_rapidfuzz.py and test_openai_grader.py files used in the examples below.

High Level Overview

The core helper function lives in:
Under the hood, build_python_grader_from_evaluation_test:
  • Takes your Eval Protocol @evaluation_test function that operates on an EvaluationRow.
  • Wraps it into a self-contained {"type": "python", "source": ...} grader module with a grade(sample, item) entrypoint.
  • Builds a minimal EvaluationRow from the OpenAI RFT inputs by:
    • Mapping item["reference_answer"] to row.ground_truth
    • Mapping item["messages"] (if present) to row.messages
    • Mapping sample["output_text"] to the last assistant message
  • Removes any runtime dependency on eval-protocol inside the grader by using simple duck-typed stand-ins for EvaluationRow, EvaluateResult, and Message.
  • Normalizes whatever your evaluation returns (e.g., EvaluateResult, EvaluationRow with .evaluation_result, or a bare number) into a single float score.
You can inspect the full implementation in eval_protocol/integrations/openai_rft.py.

Grader Constraints

When you convert an @evaluation_test into an OpenAI Python grader, it must satisfy OpenAI’s runtime limits, i.e. no network access, fixed set of packages (e.g., numpy, pandas, rapidfuzz, etc.). For more details, see OpenAI graders documentation.

Basic Usage

1. Write an Eval Protocol @evaluation_test

In example_rapidfuzz.py (from the openai-rft-quickstart repo) we define a simple evaluation test that uses rapidfuzz to score how close a model’s answer is to the ground truth:

2. Convert to a Python grader and call /graders/*

In test_openai_grader.py (also in the openai-rft-quickstart repo) we show how to:
  • Build a Python grader spec from rapidfuzz_eval
  • Validate it via /fine_tuning/alpha/graders/validate
  • Run it once via /fine_tuning/alpha/graders/run

End-to-End Example

To see an end-to-end example that takes an @evaluation_test (rapidfuzz_eval), converts it into a {"type": "python", "source": ...} grader spec with build_python_grader_from_evaluation_test, and validates/runs it against the OpenAI /graders/* HTTP APIs, clone the quickstart repo and run:
You can expect an output like:
This confirms that:
  • Your Eval Protocol @evaluation_test (rapidfuzz_eval) runs as a normal eval via pytest.
  • The same function can be converted into a type: "python" grader spec and validated / run through the OpenAI RFT graders API.
Now that you have your grader, see OpenAI’s docs on preparing your dataset and creating a reinforcement fine-tuning job.