Skip to main content
The Loops SDK ships helper functions alongside the core clients, grouped by what they operate on. baseten.loops.helpers itself exports nothing; import each helper from its submodule:
from baseten.loops.helpers.datum import attach_reference_logprobs
attach_reference_logprobs(data, reference)
list[Datum]
Return a copy of data with each Datum carrying a new ref_logprobs field in loss_fn_inputs, scored by reference.
  • data (list[Datum]): the preference batch, with each datum holding the full prompt + response sequence in model_input. For DPO batches, these are interleaved chosen/rejected pairs.
  • reference (SamplingClient): a version-pinned snapshot of the reference policy, typically returned by TrainingClient.save_weights_and_get_sampling_client before any optimizer steps.
Each datum’s sequence is scored once via a single compute_logprobs call. Scoring is sequential.