kd.summaries.ShowTexts

kd.summaries.ShowTexts#

class kauldron.summaries.ShowTexts(*, texts: typing.Annotated[typing.Any, <object object at 0x7824c478ba80>], num_texts: int = 5)[source]

Bases: kauldron.metrics.base.Metric

Show texts.

Note: This metric is not jit-compatible, as it manipulates text. So it cannot be used in the trainer (yet). Instead, it can only be used in custom kd.evals.Evaluator, like gm.evals.SamplerEvaluator.

texts

Key to the text to display.

Type:

Any

num_texts

Number of texts to collect and display. Default 5.

Type:

int

texts: Annotated[Any, <object object at 0x7824c478ba80>]
num_texts: int = 5
class State(
texts: list[str],
*,
parent: _MetricT = _EMPTY_TYPE.EMPTY,
)[source]

Bases: kauldron.metrics.auto_state.AutoState[ShowTexts]

Collects the first num_texts texts.

texts: list[str]
compute() jaxtyping.Shaped[Tensor, 'num_texts'] | jaxtyping.Shaped[ndarray, 'num_texts'] | jaxtyping.Shaped[Array, 'num_texts'][source]

Computes final metrics from intermediate values.

merge(
other: kauldron.metrics.auto_state._SelfT,
) kauldron.metrics.auto_state._SelfT[source]

Checks static fields for equality and merges data-fields.

replace(**updates)

Returns a new object replacing the specified fields with new values.

get_state(
texts: str | collections.abc.Sequence[str] | jaxtyping.Shaped[Tensor, '*b'] | jaxtyping.Shaped[ndarray, '*b'] | jaxtyping.Shaped[Array, '*b'],
) kauldron.summaries.texts.ShowTexts.State[source]
empty() kauldron.metrics.base.Metric.State[source]