Recipes

SFT: supervised fine-tuning

Supervised fine-tuning trains target responses with token cross-entropy. reef.recipe.sft:SFTRecipe ships with Reef.

What it trains #

The weights. Each report references one recorded request; the target is its metadata.teacher_context or the recorded response. Scores do not filter or weight targets, so report only what should train. Targets still train after new weights serve.

When to use it #

For demonstrations, imported responses or uploaded conversations. To learn on the model's own responses, use SDFT.

Requirements #

Slime (Train model weights) or Tinker, and one chat template, thinking mode included, for serving and training.

Run the example #

YAML
recipe:
  implementation: reef.recipe.sft:SFTRecipe
  samples:
    target: response
    max-tokens: 8192
  jobs:
    job-samples: 64
training:
  backend: slime
  options:
    global-batch-size: 64
    disable-compute-advantages-and-returns: true

Write an inference record and a report that references it for each example, and import them (file format):

jsonl
{"agent_record_id": "sft-0001", "request_type": "inference", "payload": {"model": "served-model", "messages": [{"role": "user", "content": "What is 2 + 2?"}], "response": {"choices": [{"message": {"role": "assistant", "content": "4"}}]}}}
{"agent_record_id": "sft-0001-report", "request_type": "report", "payload": {"references": ["sft-0001"]}}
Shell
reef-client import records.jsonl --url http://127.0.0.1:8900 --scenario my-agent

A job starts when job-samples reports are ready. To train again, import with new record IDs.

Configuration #

  • recipe.samples.target: demonstration (default) or response. A report references exactly one request.

  • recipe.samples.max_tokens: the longest rendered segment, prompt included, that trains; 0 sets no limit.

  • recipe.jobs.job_samples (required); recipe.config.job_parameters (job parameters).

  • Whole conversations: upload ATIF trajectories. Agent turns train unless is_copied_context: true; images are refused. A trajectory with a segment over max_tokens does not train, and SFT skips untrainable ones with a warning.

Results #

No measured results.

Code #

reef/recipe/sft/ and tests/recipe/test_sft_recipe.py.