BatchReward reward
Bases: Reward
Batched reward base class.
Subclasses receive the entire batch at once and must return one reward per sample. Use this when the reward needs cross-sample context (e.g. group-relative scores, batch normalization, paired comparisons).
To be implemented by subclasses:
call(y_true, y_pred):y_trueandy_predare lists of lengthbatch_size. MUST return alist[float]of the same length, one reward per sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Optional name for the reward instance. |
None
|
reduction
|
str
|
Optional. One of |
'mean'
|
in_mask
|
list
|
Optional. List of exact field names to keep before computing the reward. |
None
|
out_mask
|
list
|
Optional. List of exact field names to drop before computing the reward. |
None
|
in_mask_pattern
|
str
|
Optional. Regex pattern; fields whose names
match are kept (combined with |
None
|
out_mask_pattern
|
str
|
Optional. Regex pattern; fields whose names
match are dropped (combined with |
None
|
Source code in synalinks/src/rewards/batch_reward.py
compute_batch(y_true, y_pred)
async
Apply masks and return the per-sample reward list (unreduced).
This is what the trainer calls: it expects the raw list[float]
of length batch_size so it can treat each entry as that
sample's reward.