Rapidata audience
RapidataAudience #
RapidataAudience(
id: str,
name: str,
filters: list[RapidataFilter],
openapi_service: OpenAPIService,
)
Bases: RapidataAudienceBase
A Rapidata dimension audience.
A dimension audience is a group of annotators recruited via qualification examples
and (optionally) recruitment filters. Use meth:
filter to derive a
:class:RapidataFilteredAudience — a lightweight slice that reuses the same pool
without new recruiting.
Source code in src/rapidata/rapidata_client/audience/rapidata_audience.py
delete #
Deletes the audience.
Source code in src/rapidata/rapidata_client/audience/rapidata_audience.py
filter #
filter(
filters: list[RapidataFilter],
) -> RapidataFilteredAudience
Derive a filtered audience from this audience.
Applies the given filters on top of this audience's graduated annotators and returns a lightweight, filtered audience. The filtered audience reuses this audience's pool of qualified annotators — no new recruiting or onboarding takes place. The returned id can be passed to job and leaderboard creation in place of a regular audience id.
Supported filter types: CountryFilter, LanguageFilter, DemographicFilter,
and the combinators AndFilter / OrFilter / NotFilter (also via the
& / | / ~ operators).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filters
|
list[RapidataFilter]
|
One or more filters to apply. Multiple filters are
combined with a logical AND. Pass a single |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RapidataFilteredAudience |
RapidataFilteredAudience
|
A slim audience handle representing the filtered view. |
RapidataFilteredAudience
|
Only exposes operations that make sense for a filtered audience |
|
RapidataFilteredAudience
|
( |
|
RapidataFilteredAudience
|
|
|
RapidataFilteredAudience
|
audience reuses the base's qualified pool. |
Example
from rapidata import CountryFilter, DemographicFilter
base = client.audience.get_audience_by_id("aud_...")
us_under_30 = base.filter(
[CountryFilter(["US"]), DemographicFilter("age", ["18-29"])]
)
benchmark.create_leaderboard(
name="my-leaderboard",
instruction="Pick the better image",
audience_id=us_under_30.id,
)
Source code in src/rapidata/rapidata_client/audience/rapidata_audience.py
update_filters #
update_filters(
filters: list[RapidataFilter],
) -> RapidataAudience
Update the filters for this audience.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filters
|
list[RapidataFilter]
|
The new list of filters to apply to the audience. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RapidataAudience |
RapidataAudience
|
The updated audience instance (self) for method chaining. |
Source code in src/rapidata/rapidata_client/audience/rapidata_audience.py
update_name #
update_name(name: str) -> RapidataAudience
Update the name of this audience.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The new name for the audience. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RapidataAudience |
RapidataAudience
|
The updated audience instance (self) for method chaining. |
Source code in src/rapidata/rapidata_client/audience/rapidata_audience.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,
) -> RapidataAudience
Add a classification training example to this audience.
Training examples help annotators understand the task by showing them a sample datapoint with the correct answer before they start labeling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction
|
str
|
The instruction for how the data should be classified. |
required |
answer_options
|
list[str]
|
The list of possible answer options for the classification. |
required |
datapoint
|
str
|
The datapoint (URL or path) to use as the training example. |
required |
truth
|
list[str]
|
The correct answer(s) for this training example. |
required |
data_type
|
Literal['media', 'text']
|
The data type of the datapoint. Defaults to "media". |
'media'
|
context
|
str
|
Additional text context to display with the example. Defaults to None. |
None
|
media_context
|
list[str]
|
Additional image URLs / paths to display with the example. Pass a single-element list for one image, or multiple to display several images. Defaults to None. |
None
|
explanation
|
str
|
An explanation of why the truth is correct. Defaults to None. |
None
|
settings
|
Sequence[RapidataSetting]
|
Settings applied as feature flags on this example. Use the same |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RapidataAudience |
RapidataAudience
|
The audience instance (self) for method chaining. |
Source code in src/rapidata/rapidata_client/audience/rapidata_audience.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,
) -> RapidataAudience
Add a comparison training example to this audience.
Training examples help annotators understand the task by showing them a sample comparison with the correct answer before they start labeling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction
|
str
|
The instruction for the comparison task. |
required |
truth
|
str
|
The correct answer for this training example (which option should be selected). |
required |
datapoint
|
list[str]
|
A list of exactly two datapoints (URLs or paths) to compare. |
required |
data_type
|
Literal['media', 'text']
|
The data type of the datapoints. Defaults to "media". |
'media'
|
context
|
str
|
Additional text context to display with the example. Defaults to None. |
None
|
media_context
|
list[str]
|
Additional image URLs / paths to display with the example. Pass a single-element list for one image, or multiple to display several images. Defaults to None. |
None
|
explanation
|
str
|
An explanation of why the truth is correct. Defaults to None. |
None
|
settings
|
Sequence[RapidataSetting]
|
Settings applied as feature flags on this example. Use the same |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RapidataAudience |
RapidataAudience
|
The audience instance (self) for method chaining. |
Source code in src/rapidata/rapidata_client/audience/rapidata_audience.py
add_locate_example #
add_locate_example(
instruction: str,
datapoint: str,
truths: list[Box],
context: str | None = None,
media_context: list[str] | None = None,
explanation: str | None = None,
settings: Sequence[RapidataSetting] | None = None,
) -> RapidataAudience
Add a locate training example to this audience.
Training examples help annotators understand the task by showing them a sample datapoint with the correct regions before they start labeling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction
|
str
|
The instruction telling annotators what to locate. |
required |
datapoint
|
str
|
The media datapoint (URL or path) to use as the training example. |
required |
truths
|
list[Box]
|
The bounding boxes covering the correct regions to tap, as :class: |
required |
context
|
str
|
Additional text context to display with the example. Defaults to None. |
None
|
media_context
|
list[str]
|
Additional image URLs / paths to display with the example. Pass a single-element list for one image, or multiple to display several images. Defaults to None. |
None
|
explanation
|
str
|
An explanation of why the truth is correct. Defaults to None. |
None
|
settings
|
Sequence[RapidataSetting]
|
Settings applied as feature flags on this example so the qualification example matches how the actual task will be rendered. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RapidataAudience |
RapidataAudience
|
The audience instance (self) for method chaining. |
Source code in src/rapidata/rapidata_client/audience/rapidata_audience.py
add_draw_example #
add_draw_example(
instruction: str,
datapoint: str,
truths: list[Box],
context: str | None = None,
media_context: list[str] | None = None,
explanation: str | None = None,
settings: Sequence[RapidataSetting] | None = None,
) -> RapidataAudience
Add a draw training example to this audience.
Training examples help annotators understand the task by showing them a sample datapoint with the correct regions before they start labeling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction
|
str
|
The instruction telling annotators what to draw. |
required |
datapoint
|
str
|
The media datapoint (URL or path) to use as the training example. |
required |
truths
|
list[Box]
|
The bounding boxes covering the correct regions — annotators are graded on whether their drawn lines fall within any of these boxes. :class: |
required |
context
|
str
|
Additional text context to display with the example. Defaults to None. |
None
|
media_context
|
list[str]
|
Additional image URLs / paths to display with the example. Pass a single-element list for one image, or multiple to display several images. Defaults to None. |
None
|
explanation
|
str
|
An explanation of why the truth is correct. Defaults to None. |
None
|
settings
|
Sequence[RapidataSetting]
|
Settings applied as feature flags on this example so the qualification example matches how the actual task will be rendered. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RapidataAudience |
RapidataAudience
|
The audience instance (self) for method chaining. |
Source code in src/rapidata/rapidata_client/audience/rapidata_audience.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,
) -> RapidataAudience
Add a select words training example to this audience.
Training examples help annotators understand the task by showing them a sample datapoint with the correct words before they start labeling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction
|
str
|
The instruction telling annotators which words to select. |
required |
datapoint
|
str
|
The media datapoint (URL or path) to use as the training example. |
required |
sentence
|
str
|
The sentence the annotators 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 annotator 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 annotator 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
|
An explanation of why the truth is correct. Defaults to None. |
None
|
settings
|
Sequence[RapidataSetting]
|
Settings applied as feature flags on this example so the qualification example matches how the actual task will be rendered. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RapidataAudience |
RapidataAudience
|
The audience instance (self) for method chaining. |
Source code in src/rapidata/rapidata_client/audience/rapidata_audience.py
get_examples #
Get the examples for this audience as a DataFrame.
Returns a DataFrame with columns: asset, truth, context, contextAsset. Asset URLs are fully qualified with the environment's asset host.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
amount
|
int
|
Number of examples per page. |
10
|
page
|
int
|
Page number. |
1
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A DataFrame containing the examples. |