Audience example handler
AudienceExampleHandler #
Can be used to build different types of examples. That can then be added to Example sets
Source code in src/rapidata/rapidata_client/audience/audience_example_handler.py
add_classification_example #
add_classification_example(
instruction: str,
answer_options: list[str],
datapoint: str,
truth: list[str],
data_type: Literal["media", "text"] = "media",
context: str | None = None,
media_context: list[str] | None = None,
explanation: str | None = None,
settings: Sequence[RapidataSetting] | None = None,
) -> None
add a classification example to the audience
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction
|
str
|
The instruction/question to be shown to the labeler. |
required |
answer_options
|
list[str]
|
The options that the labeler can choose from to answer the question. |
required |
datapoint
|
str
|
The datapoint that the labeler will be labeling. |
required |
truth
|
list[str]
|
The correct answers to the question. |
required |
data_type
|
str
|
The type of the datapoint. Defaults to "media" (any form of image, video or audio). |
'media'
|
context
|
str
|
The context is text that will be shown in addition to the instruction. Defaults to None. |
None
|
media_context
|
list[str]
|
A list of image URLs / paths that will be shown in addition to the instruction (can be combined with context). Pass a single-element list for one image, or multiple to display several images. Defaults to None. |
None
|
explanation
|
str
|
The explanation that will be shown to the labeler if the answer is wrong. Defaults to None. |
None
|
settings
|
Sequence[RapidataSetting]
|
The list of settings to apply to the example as feature flags. Controls how the example is rendered to the labeler (e.g. |
None
|
Source code in src/rapidata/rapidata_client/audience/audience_example_handler.py
add_compare_example #
add_compare_example(
instruction: str,
truth: str,
datapoint: list[str],
data_type: Literal["media", "text"] = "media",
context: str | None = None,
media_context: list[str] | None = None,
explanation: str | None = None,
settings: Sequence[RapidataSetting] | None = None,
) -> None
add a compare example to the audience
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction
|
str
|
The instruction that the labeler will be comparing the assets on. |
required |
truth
|
str
|
The correct answer to the comparison. (has to be one of the assets) |
required |
datapoint
|
list[str]
|
The two assets that the labeler will be comparing. |
required |
data_type
|
str
|
The type of the datapoint. Defaults to "media" (any form of image, video or audio). |
'media'
|
context
|
str
|
The context is text that will be shown in addition to the instruction. Defaults to None. |
None
|
media_context
|
list[str]
|
A list of image URLs / paths that will be shown in addition to the instruction (can be combined with context). Pass a single-element list for one image, or multiple to display several images. Defaults to None. |
None
|
explanation
|
str
|
The explanation that will be shown to the labeler if the answer is wrong. Defaults to None. |
None
|
settings
|
Sequence[RapidataSetting]
|
The list of settings to apply to the example as feature flags. Controls how the example is rendered to the labeler (e.g. |
None
|
Source code in src/rapidata/rapidata_client/audience/audience_example_handler.py
add_locate_example #
add_locate_example(
instruction: str,
datapoint: str,
truths: list[Box],
required_precision: float | None = None,
required_completeness: float | None = None,
context: str | None = None,
media_context: list[str] | None = None,
explanation: str | None = None,
settings: Sequence[RapidataSetting] | None = None,
) -> None
add a locate example to the audience
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction
|
str
|
The instruction telling the labeler what to locate. |
required |
datapoint
|
str
|
The media datapoint the labeler will be locating the target in. |
required |
truths
|
list[Box]
|
The bounding boxes covering the correct regions to tap. Coordinates are ratios of the image size (0.0 to 1.0). |
required |
required_precision
|
float
|
Minimum ratio of the labeler's taps that fall inside a correct region required to pass. Defaults to None (backend default). |
None
|
required_completeness
|
float
|
Minimum ratio of the correct regions that must be hit. Defaults to None (backend default). |
None
|
context
|
str
|
The context is text that will be shown in addition to the instruction. Defaults to None. |
None
|
media_context
|
list[str]
|
A list of image URLs / paths that will be shown in addition to the instruction (can be combined with context). Pass a single-element list for one image, or multiple to display several images. Defaults to None. |
None
|
explanation
|
str
|
The explanation that will be shown to the labeler if the answer is wrong. Defaults to None. |
None
|
settings
|
Sequence[RapidataSetting]
|
The list of settings to apply to the example as feature flags. Controls how the example is rendered to the labeler. Defaults to None. |
None
|
Source code in src/rapidata/rapidata_client/audience/audience_example_handler.py
add_draw_example #
add_draw_example(
instruction: str,
datapoint: str,
truths: list[Box],
required_precision: float | None = None,
required_completeness: float | None = None,
context: str | None = None,
media_context: list[str] | None = None,
explanation: str | None = None,
settings: Sequence[RapidataSetting] | None = None,
) -> None
add a draw example to the audience
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction
|
str
|
The instruction telling the labeler what to draw. |
required |
datapoint
|
str
|
The media datapoint the labeler will be drawing on. |
required |
truths
|
list[Box]
|
The bounding boxes covering the correct regions — labelers are graded on whether their drawn lines fall within any of these boxes. Coordinates are ratios of the image size (0.0 to 1.0). |
required |
required_precision
|
float
|
Minimum ratio of the labeler's lines that fall inside a correct region required to pass. Defaults to None (backend default). |
None
|
required_completeness
|
float
|
Minimum ratio of the correct regions that must be hit. Defaults to None (backend default). |
None
|
context
|
str
|
The context is text that will be shown in addition to the instruction. Defaults to None. |
None
|
media_context
|
list[str]
|
A list of image URLs / paths that will be shown in addition to the instruction (can be combined with context). Pass a single-element list for one image, or multiple to display several images. Defaults to None. |
None
|
explanation
|
str
|
The explanation that will be shown to the labeler if the answer is wrong. Defaults to None. |
None
|
settings
|
Sequence[RapidataSetting]
|
The list of settings to apply to the example as feature flags. Controls how the example is rendered to the labeler. Defaults to None. |
None
|
Source code in src/rapidata/rapidata_client/audience/audience_example_handler.py
add_select_words_example #
add_select_words_example(
instruction: str,
datapoint: str,
sentence: str,
truths: list[int],
required_precision: float = 1,
required_completeness: float = 1,
explanation: str | None = None,
settings: Sequence[RapidataSetting] | None = None,
) -> None
add a select words example to the audience
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction
|
str
|
The instruction telling the labeler which words to select. |
required |
datapoint
|
str
|
The media datapoint the labeler will be selecting words for. |
required |
sentence
|
str
|
The sentence that the labeler will be selecting words from. (split up by spaces) |
required |
truths
|
list[int]
|
The indices of the words that are the correct answers. |
required |
required_precision
|
float
|
The required precision for the labeler to get the example correct (minimum ratio of the words selected that need to be correct). Defaults to 1. (no wrong words can be selected) |
1
|
required_completeness
|
float
|
The required completeness for the labeler to get the example correct (minimum ratio of total correct words selected). Defaults to 1. (all correct words need to be selected) |
1
|
explanation
|
str
|
The explanation that will be shown to the labeler if the answer is wrong. Defaults to None. |
None
|
settings
|
Sequence[RapidataSetting]
|
The list of settings to apply to the example as feature flags. Controls how the example is rendered to the labeler. Defaults to None. |
None
|
Source code in src/rapidata/rapidata_client/audience/audience_example_handler.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |