> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Helpers

> Utility helpers exposed by the Loops SDK alongside the core clients.

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:

```python theme={"system"}
from baseten.loops.helpers.datum import attach_reference_logprobs
```

<ParamField body="attach_reference_logprobs(data, reference)" type="list[Datum]">
  Return a copy of `data` with each [`Datum`](/reference/sdk/loops/types) 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`](/reference/sdk/loops/sampling-client)): a version-pinned snapshot of the reference policy, typically returned by [`TrainingClient.save_weights_and_get_sampling_client`](/reference/sdk/loops/training-client) before any optimizer steps.

  Each datum's sequence is scored once via a single `compute_logprobs` call. Scoring is sequential.
</ParamField>
