Send token and tensor data with Whitney’s typed JSON contract.
All Whitney v1 requests use application/json. Training data is expressed as
token ID arrays and dense tensors; you do not need generated protocol code or a
provider SDK.
Tensor values are dense and row-major. Their count must equal the product of
shape. Cross-entropy targets must be int64; optional weights must be
float32; both tensors must match the input length.
RL loops align four tensors instead of two — shifted target_tokens,
prompt-masked weights, the rollout-policy logprobs returned by sample(),
and per-token advantages — all the same length as input.token_ids.
Positions inside the prompt carry zero weight, zero logprob, and zero
advantage; only completion positions carry real values:
Here the model saw a 3-token prompt and a 2-token completion; input and
target_tokens both cover the shifted 4-token window (the completion’s last
token only ever appears as a target). The first two positions are
prompt-masked to zero; the last two carry the sampler’s own logprobs and a
single scalar advantage broadcast across the completion. Building this by
hand for every algorithm variant is exactly what
rl_datum() does — see
GRPO for the full loop.