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 that are registered for the leaderboard.
prompt_assets
property
#
Returns the prompt assets that are registered for the benchmark.
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_prompt #
add_prompt(
identifier: str | None = None,
prompt: str | None = None,
prompt_asset: str | None = None,
tags: Optional[list[str]] = None,
)
Adds a prompt to the benchmark.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str | None
|
The identifier of the prompt/asset/tags that will be used to match up the media. If not provided, it will use the prompt, asset or prompt + asset as the identifier. |
None
|
prompt
|
str | None
|
The prompt that will be used to evaluate the model. |
None
|
prompt_asset
|
str | None
|
The prompt asset that will be used to evaluate the model. Provided as a link to the asset. |
None
|
tags
|
Optional[list[str]]
|
The tags can be used to filter the leaderboard results. They will NOT be shown to the users. |
None
|
Source code in src/rapidata/rapidata_client/benchmark/rapidata_benchmark.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
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 | None = None,
min_responses_per_matchup: int | None = None,
audience_id: str | None = None,
settings: Sequence["RapidataSetting"] | 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 | None
|
The level of detail of the leaderboard. This will effect how many comparisons are done per model evaluation. (default: "low") |
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 | None
|
The id of the audience that should answer the leaderboard. Defaults to the global audience when not specified. |
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
|
Source code in src/rapidata/rapidata_client/benchmark/rapidata_benchmark.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 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 | |
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
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 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | |
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 #
Returns an aggregated elo table of all leaderboards in the benchmark.
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 win/loss matrix for all participants across all leaderboards in the benchmark.
The matrix shows pairwise comparison results where each cell [i, j] represents the number of wins participant i has against participant j.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tags
|
Optional[list[str]]
|
Filter matchups by these tags. If None, all matchups are considered. |
None
|
participant_ids
|
Optional[list[str]]
|
Filter to only include these participants. |
None
|
leaderboard_ids
|
Optional[list[str]]
|
Filter to only include matchups from these leaderboards. |
None
|
use_weighted_scoring
|
Optional[bool]
|
Whether to use weighted scoring for the matrix calculation. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A pandas DataFrame with participants as both index and columns, |
DataFrame
|
containing the pairwise win counts. |