← TinyGPT · docs · devlog · roadmap · speedup
source: docs/prds/B28-composite-reward-framework.md · view on GitHub ↗

PRD — Composite reward with named dimensions

Goal

Ship a typed CompositeReward abstraction: a reward is a bag of named scalar dimensions + weights → total. Every dimension is independently logged, plotted, and inspectable. DPO / ES / GRPO (5.1) all consume the same struct.

Stolen from Castform’s reward composition pattern (see docs/learn/castform-rl-finetune.md §1). Different from existing ES/DPO single-scalar paths.

Why now

Scope — in

Scope — out

Files (already shipped in this PR)

FileChange
native-mac/Sources/TinyGPTModel/CompositeReward.swiftnew — types + aggregation + JSON I/O
native-mac/Tests/TinyGPTModelTests/CompositeRewardTests.swiftnew — aggregation + JSON round-trip tests

Files still to touch (remaining B28 work)

FileChange
Sources/TinyGPT/Dpo.swiftaccept --reward-fn path; route the chosen/rejected scalar into a CompositeReward block
Sources/TinyGPT/Es.swiftsame
Sources/TinyGPT/Grpo.swiftuses CompositeReward natively when 5.1 ships
web/src/pages/train-viewer.astro (C10)render per-dimension lines when present in history JSONL
docs/recipes/composite-reward.mdnew — recipe

Acceptance criteria

Scaffolding (shipped this PR)

Full B28 ship (remaining)

Reference patterns

Open questions