Skip to content

Questions

Argilla uses questions to gather the feedback. The questions will be answered by users or models.

Usage Examples

To define a label question, for example, instantiate the LabelQuestion class and pass it to the Settings class.

label_question = rg.LabelQuestion(name="label", labels=["positive", "negative"])

settings = rg.Settings(
    fields=[
        rg.TextField(name="text"),
    ],
    questions=[
        label_question,
    ],
)

Questions can be combined in extensible ways based on the type of feedback you want to collect. For example, you can combine a label question with a text question to collect both a label and a text response.

label_question = rg.LabelQuestion(name="label", labels=["positive", "negative"])
text_question = rg.TextQuestion(name="response")

settings = rg.Settings(
    fields=[
        rg.TextField(name="text"),
    ],
    questions=[
        label_question,
        text_question,
    ],
)

dataset = rg.Dataset(
    name="my_dataset",
    settings=settings,
)

To add records with responses to questions, refer to the rg.Response class documentation.


LabelQuestion

Bases: QuestionPropertyBase

Source code in src/argilla/settings/_question.py
class LabelQuestion(QuestionPropertyBase):
    _model: LabelQuestionModel

    def __init__(
        self,
        name: str,
        labels: Union[List[str], Dict[str, str]],
        title: Optional[str] = None,
        description: Optional[str] = None,
        required: bool = True,
        visible_labels: Optional[int] = None,
    ) -> None:
        """ Define a new label question for `Settings` of a `Dataset`. A label \
            question is a question where the user can select one label from \
            a list of available labels.

        Parameters:
            name (str): The name of the question to be used as a reference.
            labels (Union[List[str], Dict[str, str]]): The list of available labels for the question, or a
                dictionary of key-value pairs where the key is the label and the value is the label name displayed in the UI.
            title (Optional[str]): The title of the question to be shown in the UI.
            description (Optional[str]): The description of the question to be shown in the UI.
            required (bool): If the question is required for a record to be valid. At least one question must be required.
            visible_labels (Optional[int]): The number of visible labels for the question to be shown in the UI. \
                Setting it to None show all options.
        """
        self._model = LabelQuestionModel(
            name=name,
            title=title,
            description=description,
            required=required,
            settings=LabelQuestionSettings(
                options=self._render_values_as_options(labels), visible_options=visible_labels
            ),
        )

    @classmethod
    def from_model(cls, model: LabelQuestionModel) -> "LabelQuestion":
        instance = cls(name=model.name, labels=cls._render_options_as_values(model.settings.options))
        instance._model = model
        return instance

    @classmethod
    def from_dict(cls, data: dict) -> "LabelQuestion":
        model = LabelQuestionModel(**data)
        return cls.from_model(model=model)

    ##############################
    # Public properties
    ##############################

    @property
    def labels(self) -> List[str]:
        return self._render_options_as_labels(self._model.settings.options)

    @labels.setter
    def labels(self, labels: List[str]) -> None:
        self._model.settings.options = self._render_values_as_options(labels)

    @property
    def visible_labels(self) -> Optional[int]:
        return self._model.settings.visible_options

    @visible_labels.setter
    def visible_labels(self, visible_labels: Optional[int]) -> None:
        self._model.settings.visible_options = visible_labels

__init__(name, labels, title=None, description=None, required=True, visible_labels=None)

Define a new label question for Settings of a Dataset. A label question is a question where the user can select one label from a list of available labels.

Parameters:

Name Type Description Default
name str

The name of the question to be used as a reference.

required
labels Union[List[str], Dict[str, str]]

The list of available labels for the question, or a dictionary of key-value pairs where the key is the label and the value is the label name displayed in the UI.

required
title Optional[str]

The title of the question to be shown in the UI.

None
description Optional[str]

The description of the question to be shown in the UI.

None
required bool

If the question is required for a record to be valid. At least one question must be required.

True
visible_labels Optional[int]

The number of visible labels for the question to be shown in the UI. Setting it to None show all options.

None
Source code in src/argilla/settings/_question.py
def __init__(
    self,
    name: str,
    labels: Union[List[str], Dict[str, str]],
    title: Optional[str] = None,
    description: Optional[str] = None,
    required: bool = True,
    visible_labels: Optional[int] = None,
) -> None:
    """ Define a new label question for `Settings` of a `Dataset`. A label \
        question is a question where the user can select one label from \
        a list of available labels.

    Parameters:
        name (str): The name of the question to be used as a reference.
        labels (Union[List[str], Dict[str, str]]): The list of available labels for the question, or a
            dictionary of key-value pairs where the key is the label and the value is the label name displayed in the UI.
        title (Optional[str]): The title of the question to be shown in the UI.
        description (Optional[str]): The description of the question to be shown in the UI.
        required (bool): If the question is required for a record to be valid. At least one question must be required.
        visible_labels (Optional[int]): The number of visible labels for the question to be shown in the UI. \
            Setting it to None show all options.
    """
    self._model = LabelQuestionModel(
        name=name,
        title=title,
        description=description,
        required=required,
        settings=LabelQuestionSettings(
            options=self._render_values_as_options(labels), visible_options=visible_labels
        ),
    )

MultiLabelQuestion

Bases: LabelQuestion

Source code in src/argilla/settings/_question.py
class MultiLabelQuestion(LabelQuestion):
    _model: MultiLabelQuestionModel

    def __init__(
        self,
        name: str,
        labels: Union[List[str], Dict[str, str]],
        visible_labels: Optional[int] = None,
        labels_order: Literal["natural", "suggestion"] = "natural",
        title: Optional[str] = None,
        description: Optional[str] = None,
        required: bool = True,
    ) -> None:
        """Create a new multi-label question for `Settings` of a `Dataset`. A \
            multi-label question is a question where the user can select multiple \
            labels from a list of available labels.

        Parameters:
            name (str): The name of the question to be used as a reference.
            labels (Union[List[str], Dict[str, str]]): The list of available labels for the question, or a \
                dictionary of key-value pairs where the key is the label and the value is the label name displayed in the UI.
            visible_labels (Optional[int]): The number of visible labels for the question to be shown in the UI. \
                Setting it to None show all options.
            labels_order (Literal["natural", "suggestion"]): The order of the labels in the UI. \
                Can be either "natural" (order in which they were specified) or "suggestion" (order prioritizing those associated with a suggestion). \
                The score of the suggestion will be taken into account for ordering if available.
            title (Optional[str]: The title of the question to be shown in the UI.
            description (Optional[str]): The description of the question to be shown in the UI.
            required (bool): If the question is required for a record to be valid. At least one question must be required.
        """
        self._model = MultiLabelQuestionModel(
            name=name,
            title=title,
            description=description,
            required=required,
            settings=MultiLabelQuestionSettings(
                options=self._render_values_as_options(labels),
                visible_options=visible_labels,
                options_order=labels_order,
            ),
        )

    @classmethod
    def from_model(cls, model: MultiLabelQuestionModel) -> "MultiLabelQuestion":
        instance = cls(
            name=model.name,
            labels=cls._render_options_as_values(model.settings.options),
            labels_order=model.settings.options_order,
        )
        instance._model = model

        return instance

    @classmethod
    def from_dict(cls, data: dict) -> "MultiLabelQuestion":
        model = MultiLabelQuestionModel(**data)
        return cls.from_model(model=model)

__init__(name, labels, visible_labels=None, labels_order='natural', title=None, description=None, required=True)

Create a new multi-label question for Settings of a Dataset. A multi-label question is a question where the user can select multiple labels from a list of available labels.

Parameters:

Name Type Description Default
name str

The name of the question to be used as a reference.

required
labels Union[List[str], Dict[str, str]]

The list of available labels for the question, or a dictionary of key-value pairs where the key is the label and the value is the label name displayed in the UI.

required
visible_labels Optional[int]

The number of visible labels for the question to be shown in the UI. Setting it to None show all options.

None
labels_order Literal['natural', 'suggestion']

The order of the labels in the UI. Can be either "natural" (order in which they were specified) or "suggestion" (order prioritizing those associated with a suggestion). The score of the suggestion will be taken into account for ordering if available.

'natural'
title Optional[str]

The title of the question to be shown in the UI.

None
description Optional[str]

The description of the question to be shown in the UI.

None
required bool

If the question is required for a record to be valid. At least one question must be required.

True
Source code in src/argilla/settings/_question.py
def __init__(
    self,
    name: str,
    labels: Union[List[str], Dict[str, str]],
    visible_labels: Optional[int] = None,
    labels_order: Literal["natural", "suggestion"] = "natural",
    title: Optional[str] = None,
    description: Optional[str] = None,
    required: bool = True,
) -> None:
    """Create a new multi-label question for `Settings` of a `Dataset`. A \
        multi-label question is a question where the user can select multiple \
        labels from a list of available labels.

    Parameters:
        name (str): The name of the question to be used as a reference.
        labels (Union[List[str], Dict[str, str]]): The list of available labels for the question, or a \
            dictionary of key-value pairs where the key is the label and the value is the label name displayed in the UI.
        visible_labels (Optional[int]): The number of visible labels for the question to be shown in the UI. \
            Setting it to None show all options.
        labels_order (Literal["natural", "suggestion"]): The order of the labels in the UI. \
            Can be either "natural" (order in which they were specified) or "suggestion" (order prioritizing those associated with a suggestion). \
            The score of the suggestion will be taken into account for ordering if available.
        title (Optional[str]: The title of the question to be shown in the UI.
        description (Optional[str]): The description of the question to be shown in the UI.
        required (bool): If the question is required for a record to be valid. At least one question must be required.
    """
    self._model = MultiLabelQuestionModel(
        name=name,
        title=title,
        description=description,
        required=required,
        settings=MultiLabelQuestionSettings(
            options=self._render_values_as_options(labels),
            visible_options=visible_labels,
            options_order=labels_order,
        ),
    )

RankingQuestion

Bases: QuestionPropertyBase

Source code in src/argilla/settings/_question.py
class RankingQuestion(QuestionPropertyBase):
    _model: RankingQuestionModel

    def __init__(
        self,
        name: str,
        values: Union[List[str], Dict[str, str]],
        title: Optional[str] = None,
        description: Optional[str] = None,
        required: bool = True,
    ) -> None:
        """Create a new ranking question for `Settings` of a `Dataset`. A ranking question \
            is a question where the user can rank a list of options.

        Parameters:
            name (str): The name of the question to be used as a reference.
            values (Union[List[str], Dict[str, str]]): The list of options to be ranked, or a \
                dictionary of key-value pairs where the key is the label and the value is the label name displayed in the UI.
            title (Optional[str]:) The title of the question to be shown in the UI.
            description (Optional[str]): The description of the question to be shown in the UI.
            required (bool): If the question is required for a record to be valid. At least one question must be required.
        """
        self._model = RankingQuestionModel(
            name=name,
            title=title,
            description=description,
            required=required,
            settings=RankingQuestionSettings(options=self._render_values_as_options(values)),
        )

    @classmethod
    def from_model(cls, model: RankingQuestionModel) -> "RankingQuestion":
        instance = cls(name=model.name, values=cls._render_options_as_values(model.settings.options))
        instance._model = model

        return instance

    @classmethod
    def from_dict(cls, data: dict) -> "RankingQuestion":
        model = RankingQuestionModel(**data)
        return cls.from_model(model=model)

    @property
    def values(self) -> List[str]:
        return self._render_options_as_labels(self._model.settings.options)

    @values.setter
    def values(self, values: List[int]) -> None:
        self._model.settings.options = self._render_values_as_options(values)

__init__(name, values, title=None, description=None, required=True)

Create a new ranking question for Settings of a Dataset. A ranking question is a question where the user can rank a list of options.

Parameters:

Name Type Description Default
name str

The name of the question to be used as a reference.

required
values Union[List[str], Dict[str, str]]

The list of options to be ranked, or a dictionary of key-value pairs where the key is the label and the value is the label name displayed in the UI.

required
title Optional[str]

) The title of the question to be shown in the UI.

None
description Optional[str]

The description of the question to be shown in the UI.

None
required bool

If the question is required for a record to be valid. At least one question must be required.

True
Source code in src/argilla/settings/_question.py
def __init__(
    self,
    name: str,
    values: Union[List[str], Dict[str, str]],
    title: Optional[str] = None,
    description: Optional[str] = None,
    required: bool = True,
) -> None:
    """Create a new ranking question for `Settings` of a `Dataset`. A ranking question \
        is a question where the user can rank a list of options.

    Parameters:
        name (str): The name of the question to be used as a reference.
        values (Union[List[str], Dict[str, str]]): The list of options to be ranked, or a \
            dictionary of key-value pairs where the key is the label and the value is the label name displayed in the UI.
        title (Optional[str]:) The title of the question to be shown in the UI.
        description (Optional[str]): The description of the question to be shown in the UI.
        required (bool): If the question is required for a record to be valid. At least one question must be required.
    """
    self._model = RankingQuestionModel(
        name=name,
        title=title,
        description=description,
        required=required,
        settings=RankingQuestionSettings(options=self._render_values_as_options(values)),
    )

TextQuestion

Bases: QuestionPropertyBase

Source code in src/argilla/settings/_question.py
class TextQuestion(QuestionPropertyBase):
    _model: TextQuestionModel

    def __init__(
        self,
        name: str,
        title: Optional[str] = None,
        description: Optional[str] = None,
        required: bool = True,
        use_markdown: bool = False,
    ) -> None:
        """Create a new text question for `Settings` of a `Dataset`. A text question \
            is a question where the user can input text.

        Parameters:
            name (str): The name of the question to be used as a reference.
            title (Optional[str]): The title of the question to be shown in the UI.
            description (Optional[str]): The description of the question to be shown in the UI.
            required (bool): If the question is required for a record to be valid. At least one question must be required.
            use_markdown (Optional[bool]): Whether to render the markdown in the UI. When True, you will be able \
                to use all the Markdown features for text formatting, including LaTex formulas and embedding multimedia content and PDFs.
        """
        self._model = TextQuestionModel(
            name=name,
            title=title,
            description=description,
            required=required,
            settings=TextQuestionSettings(use_markdown=use_markdown),
        )

    @classmethod
    def from_model(cls, model: TextQuestionModel) -> "TextQuestion":
        instance = cls(name=model.name)
        instance._model = model

        return instance

    @classmethod
    def from_dict(cls, data: dict) -> "TextQuestion":
        model = TextQuestionModel(**data)
        return cls.from_model(model=model)

    @property
    def use_markdown(self) -> bool:
        return self._model.settings.use_markdown

    @use_markdown.setter
    def use_markdown(self, use_markdown: bool) -> None:
        self._model.settings.use_markdown = use_markdown

__init__(name, title=None, description=None, required=True, use_markdown=False)

Create a new text question for Settings of a Dataset. A text question is a question where the user can input text.

Parameters:

Name Type Description Default
name str

The name of the question to be used as a reference.

required
title Optional[str]

The title of the question to be shown in the UI.

None
description Optional[str]

The description of the question to be shown in the UI.

None
required bool

If the question is required for a record to be valid. At least one question must be required.

True
use_markdown Optional[bool]

Whether to render the markdown in the UI. When True, you will be able to use all the Markdown features for text formatting, including LaTex formulas and embedding multimedia content and PDFs.

False
Source code in src/argilla/settings/_question.py
def __init__(
    self,
    name: str,
    title: Optional[str] = None,
    description: Optional[str] = None,
    required: bool = True,
    use_markdown: bool = False,
) -> None:
    """Create a new text question for `Settings` of a `Dataset`. A text question \
        is a question where the user can input text.

    Parameters:
        name (str): The name of the question to be used as a reference.
        title (Optional[str]): The title of the question to be shown in the UI.
        description (Optional[str]): The description of the question to be shown in the UI.
        required (bool): If the question is required for a record to be valid. At least one question must be required.
        use_markdown (Optional[bool]): Whether to render the markdown in the UI. When True, you will be able \
            to use all the Markdown features for text formatting, including LaTex formulas and embedding multimedia content and PDFs.
    """
    self._model = TextQuestionModel(
        name=name,
        title=title,
        description=description,
        required=required,
        settings=TextQuestionSettings(use_markdown=use_markdown),
    )

RatingQuestion

Bases: QuestionPropertyBase

Source code in src/argilla/settings/_question.py
class RatingQuestion(QuestionPropertyBase):
    _model: RatingQuestionModel

    def __init__(
        self,
        name: str,
        values: List[int],
        title: Optional[str] = None,
        description: Optional[str] = None,
        required: bool = True,
    ) -> None:
        """Create a new rating question for `Settings` of a `Dataset`. A rating question \
            is a question where the user can select a value from a sequential list of options.

        Parameters:
            name (str): The name of the question to be used as a reference.
            values (List[int]): The list of selectable values. It should be defined in the range [0, 10].
            title (Optional[str]:) The title of the question to be shown in the UI.
            description (Optional[str]): The description of the question to be shown in the UI.
            required (bool): If the question is required for a record to be valid. At least one question must be required.
        """
        self._model = RatingQuestionModel(
            name=name,
            title=title,
            description=description,
            required=required,
            values=values,
            settings=RatingQuestionSettings(options=self._render_values_as_options(values)),
        )

    @classmethod
    def from_model(cls, model: RatingQuestionModel) -> "RatingQuestion":
        instance = cls(name=model.name, values=cls._render_options_as_values(model.settings.options))
        instance._model = model

        return instance

    @classmethod
    def from_dict(cls, data: dict) -> "RatingQuestion":
        model = RatingQuestionModel(**data)
        return cls.from_model(model=model)

    @property
    def values(self) -> List[int]:
        return self._render_options_as_labels(self._model.settings.options)

    @values.setter
    def values(self, values: List[int]) -> None:
        self._model.values = self._render_values_as_options(values)

__init__(name, values, title=None, description=None, required=True)

Create a new rating question for Settings of a Dataset. A rating question is a question where the user can select a value from a sequential list of options.

Parameters:

Name Type Description Default
name str

The name of the question to be used as a reference.

required
values List[int]

The list of selectable values. It should be defined in the range [0, 10].

required
title Optional[str]

) The title of the question to be shown in the UI.

None
description Optional[str]

The description of the question to be shown in the UI.

None
required bool

If the question is required for a record to be valid. At least one question must be required.

True
Source code in src/argilla/settings/_question.py
def __init__(
    self,
    name: str,
    values: List[int],
    title: Optional[str] = None,
    description: Optional[str] = None,
    required: bool = True,
) -> None:
    """Create a new rating question for `Settings` of a `Dataset`. A rating question \
        is a question where the user can select a value from a sequential list of options.

    Parameters:
        name (str): The name of the question to be used as a reference.
        values (List[int]): The list of selectable values. It should be defined in the range [0, 10].
        title (Optional[str]:) The title of the question to be shown in the UI.
        description (Optional[str]): The description of the question to be shown in the UI.
        required (bool): If the question is required for a record to be valid. At least one question must be required.
    """
    self._model = RatingQuestionModel(
        name=name,
        title=title,
        description=description,
        required=required,
        values=values,
        settings=RatingQuestionSettings(options=self._render_values_as_options(values)),
    )

SpanQuestion

Bases: QuestionPropertyBase

Source code in src/argilla/settings/_question.py
class SpanQuestion(QuestionPropertyBase):
    _model: SpanQuestionModel

    def __init__(
        self,
        name: str,
        field: str,
        labels: Union[List[str], Dict[str, str]],
        allow_overlapping: bool = False,
        visible_labels: Optional[int] = None,
        title: Optional[str] = None,
        description: Optional[str] = None,
        required: bool = True,
    ):
        """ Create a new span question for `Settings` of a `Dataset`. A span question \
            is a question where the user can select a section of text within a text field \
            and assign it a label.

            Parameters:
                name (str): The name of the question to be used as a reference.
                field (str): The name of the text field where the span question will be applied.
                labels (Union[List[str], Dict[str, str]]): The list of available labels for the question, or a \
                    dictionary of key-value pairs where the key is the label and the value is the label name displayed in the UI.
                allow_overlapping (bool) This value specifies whether overlapped spans are allowed or not.
                visible_labels (Optional[int]): The number of visible labels for the question to be shown in the UI. \
                    Setting it to None show all options.
                title (Optional[str]:) The title of the question to be shown in the UI.
                description (Optional[str]): The description of the question to be shown in the UI.
                required (bool): If the question is required for a record to be valid. At least one question must be required.
            """
        self._model = SpanQuestionModel(
            name=name,
            title=title,
            description=description,
            required=required,
            settings=SpanQuestionSettings(
                field=field,
                allow_overlapping=allow_overlapping,
                visible_options=visible_labels,
                options=self._render_values_as_options(labels),
            ),
        )

    @property
    def name(self):
        return self._model.name

    @property
    def field(self):
        return self._model.settings.field

    @field.setter
    def field(self, field: str):
        self._model.settings.field = field

    @property
    def allow_overlapping(self):
        return self._model.settings.allow_overlapping

    @allow_overlapping.setter
    def allow_overlapping(self, allow_overlapping: bool):
        self._model.settings.allow_overlapping = allow_overlapping

    @property
    def visible_labels(self) -> Optional[int]:
        return self._model.settings.visible_options

    @visible_labels.setter
    def visible_labels(self, visible_labels: Optional[int]) -> None:
        self._model.settings.visible_options = visible_labels

    @property
    def labels(self) -> List[str]:
        return self._render_options_as_labels(self._model.settings.options)

    @labels.setter
    def labels(self, labels: List[str]) -> None:
        self._model.settings.options = self._render_values_as_options(labels)

    @classmethod
    def from_model(cls, model: SpanQuestionModel) -> "SpanQuestion":
        instance = cls(
            name=model.name,
            field=model.settings.field,
            labels=cls._render_options_as_values(model.settings.options),
        )
        instance._model = model

        return instance

    @classmethod
    def from_dict(cls, data: dict) -> "SpanQuestion":
        model = SpanQuestionModel(**data)
        return cls.from_model(model=model)

__init__(name, field, labels, allow_overlapping=False, visible_labels=None, title=None, description=None, required=True)

Create a new span question for Settings of a Dataset. A span question is a question where the user can select a section of text within a text field and assign it a label.

Parameters:

Name Type Description Default
name str

The name of the question to be used as a reference.

required
field str

The name of the text field where the span question will be applied.

required
labels Union[List[str], Dict[str, str]]

The list of available labels for the question, or a dictionary of key-value pairs where the key is the label and the value is the label name displayed in the UI.

required
visible_labels Optional[int]

The number of visible labels for the question to be shown in the UI. Setting it to None show all options.

None
title Optional[str]

) The title of the question to be shown in the UI.

None
description Optional[str]

The description of the question to be shown in the UI.

None
required bool

If the question is required for a record to be valid. At least one question must be required.

True
Source code in src/argilla/settings/_question.py
def __init__(
    self,
    name: str,
    field: str,
    labels: Union[List[str], Dict[str, str]],
    allow_overlapping: bool = False,
    visible_labels: Optional[int] = None,
    title: Optional[str] = None,
    description: Optional[str] = None,
    required: bool = True,
):
    """ Create a new span question for `Settings` of a `Dataset`. A span question \
        is a question where the user can select a section of text within a text field \
        and assign it a label.

        Parameters:
            name (str): The name of the question to be used as a reference.
            field (str): The name of the text field where the span question will be applied.
            labels (Union[List[str], Dict[str, str]]): The list of available labels for the question, or a \
                dictionary of key-value pairs where the key is the label and the value is the label name displayed in the UI.
            allow_overlapping (bool) This value specifies whether overlapped spans are allowed or not.
            visible_labels (Optional[int]): The number of visible labels for the question to be shown in the UI. \
                Setting it to None show all options.
            title (Optional[str]:) The title of the question to be shown in the UI.
            description (Optional[str]): The description of the question to be shown in the UI.
            required (bool): If the question is required for a record to be valid. At least one question must be required.
        """
    self._model = SpanQuestionModel(
        name=name,
        title=title,
        description=description,
        required=required,
        settings=SpanQuestionSettings(
            field=field,
            allow_overlapping=allow_overlapping,
            visible_options=visible_labels,
            options=self._render_values_as_options(labels),
        ),
    )