Rapidata benchmark
RapidataBenchmark #
An instance of a Rapidata benchmark.
Used to interact with a specific benchmark in the Rapidata system, such as retrieving prompts and evaluating models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name that will be used to identify the benchmark on the overview. |
required |
id
|
str
|
The id of the benchmark. |
required |
openapi_service
|
OpenAPIService
|
The OpenAPI service to use to interact with the Rapidata API. |
required |
Source code in src/rapidata/rapidata_client/benchmark/rapidata_benchmark.py
prompts
property
#
Returns the prompts as originally provided, in the order they were registered.
english_prompts
property
#
Returns the prompts translated to English, aligned by index with prompts.
The translations are produced server-side, so accessing this after
add_prompts triggers a one-off re-fetch of the prompt set.
prompt_assets
property
#
Returns the prompt assets that are registered for the benchmark.
tags
property
#
Returns the tag values registered for the benchmark, aligned by index with prompts.
This is the flat, values-only view of the tags. It is kept for
backwards compatibility — prefer structured_tags for the
(value + category) representation.
structured_tags
property
#
structured_tags: list[list[Tag]]
Returns the structured tags registered for the benchmark, aligned by index with prompts.
Each :class:Tag carries a value and an optional category. Tags
are used to filter and organize leaderboard results and are NOT shown to
the annotators.
origins
property
#
origins: list[Origin | None]
Returns the origin of each prompt, aligned by index with prompts.
A prompt without an origin is represented as None.
leaderboards
property
#
leaderboards: list[RapidataLeaderboard]
Returns the leaderboards that are registered for the benchmark.
participants
property
#
participants: list[BenchmarkParticipant]
Returns the participants that are registered for the benchmark.
add_prompts #
add_prompts(
identifiers: Optional[list[str]] = None,
prompts: Optional[list[str | None] | list[str]] = None,
prompt_assets: Optional[
list[str | None] | list[str]
] = None,
tags: Optional[
Sequence[Sequence[str | Tag] | None]
] = None,
origins: Optional[Sequence[Origin | str | None]] = None,
) -> None
Adds one or more prompts to the benchmark. Everything is matched up by the indexes of the lists.
prompts or identifiers must be provided, as well as prompts or prompt_assets.
The prompts are uploaded concurrently. A failed upload does not abort the rest: every prompt is attempted, failures are logged, and only the prompts that succeeded are registered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifiers
|
Optional[list[str]]
|
The identifiers of the prompts/assets/tags that will be used to match up the media. If not provided, it will use the prompts as the identifiers. |
None
|
prompts
|
Optional[list[str | None] | list[str]]
|
The prompts that will be registered for the benchmark. |
None
|
prompt_assets
|
Optional[list[str | None] | list[str]]
|
The prompt assets that will be registered for the benchmark. |
None
|
tags
|
Optional[Sequence[Sequence[str | Tag] | None]]
|
The tags per prompt, used to filter and organize the leaderboard results. They are NOT shown to the users. Each entry is a list of plain strings, a list of :class: |
None
|
origins
|
Optional[Sequence[Origin | str | None]]
|
The origin of each prompt (e.g. a source dataset). Each entry is a plain string (converted to |
None
|
Example
# Plain strings are all you need when you don't want categories.
benchmark.add_prompts(
identifiers=["id1", "id2"],
prompts=["prompt 1", "prompt 2"],
prompt_assets=["https://assets.rapidata.ai/prompt_1.jpg", "https://assets.rapidata.ai/prompt_2.jpg"],
tags=[["landscape", "outdoor"], ["portrait"]],
origins=["coco", "coco"],
)
# Reach for Tag only where you want to group tags by category.
from rapidata import Tag
benchmark.add_prompts(
identifiers=["id3"],
prompts=["prompt 3"],
tags=[[Tag("landscape", category="scene"), "outdoor"]],
)
Source code in src/rapidata/rapidata_client/benchmark/rapidata_benchmark.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 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 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 | |
update_prompt #
update_prompt(
identifier: str,
tags: Optional[Sequence[str | Tag]] = None,
origin: Origin | str | None = None,
) -> None
Updates the tags and/or origin of an existing prompt.
Only the provided fields are changed: pass tags to replace the
prompt's tags, origin to set its origin, or both. A field left as
None is not sent and the server leaves it unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The identifier of the prompt to update. Must already be registered on the benchmark. |
required |
tags
|
Optional[Sequence[str | Tag]]
|
The new tags for the prompt — plain strings, :class: |
None
|
origin
|
Origin | str | None
|
The new origin (an :class: |
None
|
Source code in src/rapidata/rapidata_client/benchmark/rapidata_benchmark.py
create_leaderboard #
create_leaderboard(
name: str,
instruction: str,
show_prompt: bool = False,
show_prompt_asset: bool = False,
inverse_ranking: bool = False,
level_of_detail: LevelOfDetail | int | None = None,
min_responses_per_matchup: int | None = None,
audience_id: str | RapidataAudienceBase | None = None,
settings: Sequence["RapidataSetting"] | None = None,
included_tags: list[str] | None = None,
excluded_tags: list[str] | None = None,
) -> RapidataLeaderboard
Creates a new leaderboard for the benchmark.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the leaderboard. (not shown to the users) |
required |
instruction
|
str
|
The instruction decides how the models will be evaluated. |
required |
show_prompt
|
bool
|
Whether to show the prompt to the users. (default: False) |
False
|
show_prompt_asset
|
bool
|
Whether to show the prompt asset to the users. (only works if the prompt asset is a URL) (default: False) |
False
|
inverse_ranking
|
bool
|
Whether to inverse the ranking of the leaderboard. (if the question is inversed, e.g. "Which video is worse?") |
False
|
level_of_detail
|
LevelOfDetail | int | None
|
Sets the leaderboard's response budget — the total number of comparison responses collected per model evaluation. A larger budget buys more matchups and therefore more precise standings, at the cost of a slower, more expensive evaluation. Either one of the named levels — 'debug' (20 responses), 'low' (2,000), 'medium' (4,000), 'high' (8,000), 'very high' (16,000) — or a positive integer for a custom budget. (default: None, server decides) |
None
|
min_responses_per_matchup
|
int | None
|
The minimum number of responses required to be considered for the leaderboard. (default: 3) |
None
|
audience_id
|
str | RapidataAudienceBase | None
|
The audience that should answer the leaderboard. Pass either the audience id, a :class: |
None
|
settings
|
Sequence['RapidataSetting'] | None
|
The settings that should be applied to the leaderboard. Will determine the behavior of the tasks on the leaderboard. (default: []) |
None
|
included_tags
|
list[str] | None
|
Restricts which of the benchmark's prompts this leaderboard collects matchups for: only prompts carrying at least one of these tag values are used. When empty or not specified (the default) every prompt is eligible. Note that a non-empty list drops untagged prompts. (default: None) |
None
|
excluded_tags
|
list[str] | None
|
Prompt tag values to skip when collecting matchups. Always wins over |
None
|
Do not confuse either tag argument with the tags argument of
:meth:RapidataLeaderboard.get_standings: that filters the standings you read
back out, whereas these decide which prompts get matchups collected in the first
place.
Both match on the tag value; a tag's category is irrelevant. They are
resolved when a run starts rather than snapshotted at creation, so re-tagging a
prompt changes which future runs pick it up. They are read back via the
read-only :attr:RapidataLeaderboard.included_tags /
:attr:RapidataLeaderboard.excluded_tags and cannot be changed afterwards — to
re-scope, create a new leaderboard.
Source code in src/rapidata/rapidata_client/benchmark/rapidata_benchmark.py
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 | |
evaluate_model #
evaluate_model(
name: str,
media: list[str],
identifiers: list[str] | None = None,
prompts: list[str] | None = None,
data_type: Literal["media", "text"] = "media",
) -> None
Evaluates a model on the benchmark across all leaderboards.
prompts or identifiers must be provided to match the media.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the model. |
required |
media
|
list[str]
|
The generated media or text that will be used to evaluate the model. |
required |
identifiers
|
list[str] | None
|
The identifiers that correspond to the media. The order of the identifiers must match the order of the media. The identifiers that are used must be registered for the benchmark. To see the registered identifiers, use the identifiers property. |
None
|
prompts
|
list[str] | None
|
The prompts that correspond to the media. The order of the prompts must match the order of the media. |
None
|
data_type
|
Literal['media', 'text']
|
The type of data being provided. Use "media" for images/videos/audio (default) or "text" for text content. |
'media'
|
Source code in src/rapidata/rapidata_client/benchmark/rapidata_benchmark.py
add_model #
add_model(
name: str,
media: list[str],
identifiers: list[str] | None = None,
prompts: list[str] | None = None,
data_type: Literal["media", "text"] = "media",
) -> BenchmarkParticipant
Adds a model to the benchmark without immediately submitting it for evaluation.
This method creates a participant, uploads media, but does NOT submit the participant.
Use participant.run() or benchmark.run() to submit afterwards.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the model. |
required |
media
|
list[str]
|
The generated media or text that will be used to evaluate the model. |
required |
identifiers
|
list[str] | None
|
The identifiers that correspond to the media. The order of the identifiers must match the order of the media. The identifiers that are used must be registered for the benchmark. To see the registered identifiers, use the identifiers property. |
None
|
prompts
|
list[str] | None
|
The prompts that correspond to the media. The order of the prompts must match the order of the media. |
None
|
data_type
|
Literal['media', 'text']
|
The type of data being provided. Use "media" for images/videos/audio (default) or "text" for text content. |
'media'
|
Returns:
| Type | Description |
|---|---|
BenchmarkParticipant
|
The created BenchmarkParticipant instance. |
Source code in src/rapidata/rapidata_client/benchmark/rapidata_benchmark.py
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | |
run #
Submits all participants that are in CREATED state.
This is a convenience method to submit all unsubmitted participants at once.
Source code in src/rapidata/rapidata_client/benchmark/rapidata_benchmark.py
view #
Views the benchmark.
Source code in src/rapidata/rapidata_client/benchmark/rapidata_benchmark.py
get_overall_standings #
get_overall_standings(
tags: Optional[list[str]] = None,
leaderboard_ids: Optional[list[str]] = None,
) -> DataFrame
Returns an aggregated elo table of all leaderboards in the benchmark.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tags
|
Optional[list[str]]
|
Filter standings by these tags. If None, all tags are considered. |
None
|
leaderboard_ids
|
Optional[list[str]]
|
Filter to only include matchups from these leaderboards. If None, all leaderboards are considered. |
None
|
Source code in src/rapidata/rapidata_client/benchmark/rapidata_benchmark.py
get_win_loss_matrix #
get_win_loss_matrix(
tags: Optional[list[str]] = None,
participant_ids: Optional[list[str]] = None,
leaderboard_ids: Optional[list[str]] = None,
use_weighted_scoring: Optional[bool] = None,
) -> DataFrame
Returns the pairwise win/loss matrix aggregated across the benchmark's leaderboards.
The returned DataFrame is square, with participant names on both the index
(rows) and columns. Cell [i, j] is how often participant i (row) beat
participant j (column) in their direct matchups, summed over every
leaderboard in scope. Read a row to see how a model did against every
opponent; the diagonal (a model against itself) is always 0. This is the
head-to-head breakdown behind :meth:get_overall_standings, which collapses
the same matchups into a single Elo score per model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tags
|
Optional[list[str]]
|
Only count matchups carrying one of these prompt tags. If None, every matchup is included; if an empty list, none are. |
None
|
participant_ids
|
Optional[list[str]]
|
Restrict the matrix to these participants. If None, all participants are included. |
None
|
leaderboard_ids
|
Optional[list[str]]
|
Only aggregate matchups from these leaderboards. If None, all leaderboards in the benchmark are included. |
None
|
use_weighted_scoring
|
Optional[bool]
|
If True, each matchup is weighted by the responding
annotators' reliability ( |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A pandas DataFrame indexed by participant name on both axes, where cell |
DataFrame
|
|
DataFrame
|
participant over the column participant. |