autointent.schemas.Sample#

class autointent.schemas.Sample(/, **data)#

Bases: pydantic.BaseModel

Represents a sample with an utterance and an optional label.

Parameters:
  • utterance – The textual content of the sample.

  • label – The label(s) associated with the sample. Can be a single label (integer) or a list of labels (integers). Defaults to None for unlabeled samples.

  • data (Any)

utterance: str#
label: autointent.custom_types.LabelType | None = None#
validate_sample()#

Validate the sample after model instantiation.

This method ensures that the label field adheres to the expected constraints: - If label is provided, it must be a non-negative integer or a list of non-negative integers. - Multilabel samples must have at least one valid label.

Raises:

ValueError – If the label field is empty for a multilabel sample or contains invalid (negative) values.

Returns:

The validated sample instance.

Return type:

Sample