API Reference¶
Public API¶
steb.core.get_model(model_name_or_path, truncate=False, max_tokens=None)
¶
Loads a STEB model.
Dispatches in four stages
- Match the prefix of
model_name_or_path(the part before":") against each registered class'ssupported_modelslist. - If the path points at a LISA checkpoint directory (detected via
:func:
is_lisa_model), route to :class:LISAModel. - If nothing matched, inspect the HuggingFace config and route
auto-regressive LMs to :class:
CausalModel. - Otherwise fall back to :class:
HFModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name_or_path
|
str
|
The name or path of the model to load. |
required |
truncate
|
bool
|
If True, truncate each text to the token cap instead of chunking and mean-pooling. No-op for non-tokenizer models. |
False
|
max_tokens
|
Optional[int]
|
Optional per-text token cap, capped at the model's native maximum. No-op for non-tokenizer models. |
None
|
Returns:
| Type | Description |
|---|---|
|
An instance of a STEBModel. |
Source code in steb/core.py
steb.core.get_all_datasets()
¶
Retrieves a list of all available STEB datasets.
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of all available dataset names. |
steb.core.get_supported_datasets(task_name)
¶
Retrieves a list of datasets that support the given task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_name
|
str
|
The name of the task. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of supported dataset names. |
Source code in steb/core.py
steb.core.get_supported_tasks()
¶
steb.core.evaluate(model, datasets, episode_sizes=None, task_name=None, n_episodes_per_class=None, batch_size=32, force_reload=False, force_rerun=False, force_rerun_oa=False, progress_bar=False, output_folder=RESULTS_DIR, seed=42, run_name=None)
¶
Evaluates a model on a list of datasets for a given task.
Individual dataset/task failures are caught and logged rather than
crashing the entire run. A summary of successes and failures is
printed at the end, and a JSON log is written to
{output_folder}/logs/.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
The model to evaluate. |
required | |
datasets
|
List[str]
|
A list of dataset names to evaluate on. |
required |
episode_sizes
|
Optional[List[int]]
|
A list of episode sizes to evaluate. If None, uses per-task defaults from TASK_DEFAULTS. |
None
|
task_name
|
Optional[str]
|
The name of the task to evaluate. If None, runs all tasks. |
None
|
n_episodes_per_class
|
Optional[int]
|
The number of episodes per class. If None, uses per-task defaults from TASK_DEFAULTS. |
None
|
batch_size
|
int
|
The batch size for embedding. |
32
|
force_reload
|
bool
|
Whether to force reload the datasets. |
False
|
force_rerun
|
bool
|
Whether to re-run evaluations even if metrics already exist. |
False
|
force_rerun_oa
|
bool
|
Whether to re-run the order_alignment task only,
even if its metrics file already exists. Ignored when
|
False
|
progress_bar
|
bool
|
Whether to show a progress bar. |
False
|
output_folder
|
str
|
The folder to save the results to. |
RESULTS_DIR
|
seed
|
int
|
The random seed to use. |
42
|
run_name
|
Optional[str]
|
An optional label for this run (e.g. preset name). Used in the log filename alongside the model name. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A dictionary with "successes", "failures", and "log_path" keys. |
Source code in steb/core.py
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 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 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 744 745 746 747 748 749 | |
steb.core.preview(datasets, task_name=None, episode_sizes=None, n_episodes_per_class=None, output_file=None, show_summary=True)
¶
Previews dataset statistics for a benchmark run without loading a model.
For each dataset/task/episode_size combination, reports class counts, resolved n_episodes_per_class, and which classes would be dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasets
|
List[str]
|
A list of dataset names to preview. |
required |
task_name
|
Optional[str]
|
The task to preview. If None, previews all tasks. |
None
|
episode_sizes
|
Optional[List[int]]
|
Episode sizes to preview. If None, uses per-task defaults. |
None
|
n_episodes_per_class
|
Optional[int]
|
Override for n_episodes_per_class. If None, uses per-task defaults. |
None
|
output_file
|
Optional[str]
|
Optional path to write the preview report to. |
None
|
show_summary
|
bool
|
Whether to print the summary block. Set to False when the caller handles its own summary (e.g. preset mode). |
True
|
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
A list of result dicts, one per dataset/task/episode_size combination. |
Source code in steb/core.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 | |
Base Model¶
steb.models.base.STEBModel
¶
Bases: ABC
Abstract base class for text embedding models.
Subclasses that tokenize input may set effective_max_tokens in
their constructor to the resolved per-text token cap when the user
has opted into truncation mode or specified an explicit max_tokens
cap. None means default chunk-and-pool behavior with no tagging.
Source code in steb/models/base.py
embed_multiple(episodes, batch_size, show_progress=False)
abstractmethod
¶
Embeds a list of episodes, where each episode is a list of texts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episodes
|
List[List[str]]
|
A list of episodes to embed. |
required |
batch_size
|
int
|
The batch size to use for embedding. |
required |
show_progress
|
bool
|
Whether to show a progress bar. |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
A numpy array of embeddings. |