run_experiment
create_judge_experiment
create_judge_experiment(
create_judge_file: bool,
experiment: Experiment,
template_prompts: dict[str, str] | None,
judge_settings: dict | None,
judge: list[str] | str | None,
) -> Experiment | None
Create a judge experiment if the create_judge_file flag is True.
This experiment object should have been processed before, so that the completed responses are available. If the experiment has not been processed, an error is raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
create_judge_file
|
bool
|
Flag to indicate if a judge experiment should be created |
required |
experiment
|
Experiment
|
The experiment object to create the judge experiment from. This is used to obtain the list of completed responses and to create the judge experiment and file name. |
required |
template_prompts
|
str | None
|
The template prompt string to be used for the judge |
required |
judge_settings
|
dict | None
|
The judge settings dictionary to be used for the judge |
required |
judge
|
list[str] | str | None
|
The judge(s) to be used for the judge experiment. These must be keys in the judge settings dictionary |
required |
Returns:
| Type | Description |
|---|---|
Experiment | None
|
The judge experiment object if create_judge_file is True, otherwise None |
Source code in src/prompto/scripts/run_experiment.py
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 | |
create_rephrase_experiment
create_rephrase_experiment(
create_rephrase_file: bool,
experiment: Experiment,
template_prompts: list[str] | None,
rephrase_settings: dict | None,
rephrase_model: list[str] | str | None,
) -> tuple[Experiment | None, Rephraser | None]
Create a rephrase experiment if the create_rephrase_file flag is True.
This experiment object should have been processed before, so that the completed responses are available. If the experiment has not been processed, an error is raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
create_rephrase_file
|
bool
|
Flag to indicate if a rephrase experiment should be created |
required |
experiment
|
Experiment
|
The experiment object to create the rephrase experiment from. This is used to obtain the list of completed responses and to create the rephrase experiment and file name. |
required |
template_prompts
|
list[str] | None
|
The template prompt string to be used for the rephrase |
required |
rephrase_settings
|
dict | None
|
The rephrase settings dictionary to be used for the rephrase |
required |
rephrase_model
|
list[str] | str | None
|
The rephrase(s) to be used for the rephrase experiment. These must be keys in the rephrase settings dictionary |
required |
Returns:
| Type | Description |
|---|---|
tuple[Experiment | None, Rephraser | None]
|
A tuple containing the rephrase experiment object and the Rephraser object if create_rephrase_file is True, otherwise a tuple of two None |
Source code in src/prompto/scripts/run_experiment.py
load_env_file
Load environment variables from a .env file using dotenv.load_dotenv.
Will log info if the file is loaded successfully and a warning if the file is not found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_file
|
str
|
Path to the .env file to load |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Returned from dotenv.load_dotenv |
Source code in src/prompto/scripts/run_experiment.py
load_judge_args
load_judge_args(
judge_folder_arg: str | None,
judge_arg: str | None,
judge_templates_arg: str | None,
) -> tuple[bool, dict[str, str], dict, list[str]]
Load the judge arguments and parse them to get the template prompt(s), judge settings and judges to use.
Also returns a boolean indicating if a judge file should be created and processed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
judge_folder_arg
|
str | None
|
Path to judge folder containing the template.txt and settings.json files |
required |
judge_arg
|
str | None
|
Judge(s) to be used separated by commas. These must be keys in the judge settings dictionary |
required |
judge_templates_arg
|
str | None
|
Template file(s) to be used for the judge separated by commas |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, list[str], dict, list[str]]
|
A tuple containing the boolean indicating if a judge file should be created, the template prompt string, the judge settings dictionary and the list of judges to use |
Source code in src/prompto/scripts/run_experiment.py
load_max_queries_json
Load the max queries json file if it is provided and returns as a dictionary.
Raises errors if either the file does not exist or if it is not a json file.
If the max_queries_json is None, an empty dictionary is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_queries_json
|
str | None
|
Path to the json file containing the maximum queries per minute for each API and model or group as a dictionary. If None, an empty dictionary is returned |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The dictionary containing the maximum queries per minute for each API and model or group |
Source code in src/prompto/scripts/run_experiment.py
load_rephrase_args
load_rephrase_args(
rephrase_folder_arg: str | None,
rephrase_model_arg: str | None,
rephrase_templates_arg: str | None,
) -> tuple[bool, list[str], dict, list[str]]
Load the rephrase arguments and parse them to get the template prompts, rephrase settings and models for rephrasal.
Also returns a boolean indicating if a rephrase file should be created and processed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rephrase_folder_arg
|
str | None
|
Path to judge folder containing the template.txt and settings.json files |
required |
rephrase_model_arg
|
str | None
|
Rephrase model(s) to be used separated by commas. These must be keys in the rephrase settings dictionary |
required |
rephrase_templates_arg
|
str | None
|
Template file to be used for the rephrasals. This must be .txt files in the rephrase folder |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, list[str], dict, list[str]]
|
A tuple containing the boolean indicating if a judge file should be created, the template prompt string, the judge settings dictionary and the judge list |
Source code in src/prompto/scripts/run_experiment.py
main
async
Runs a particular experiment in the input data folder.
Source code in src/prompto/scripts/run_experiment.py
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 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 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 | |
parse_file_path_and_check_in_input
parse_file_path_and_check_in_input(
file_path: str, settings: Settings, move_to_input: bool = False
) -> str
Parse the file path to get the experiment file name.
If the file is not in the input folder, it is either moved or copied there for processing depending on the move_to_input flag.
Raises errors if either the file does not exist or if it is not a jsonl file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the experiment file |
required |
settings
|
Settings
|
Settings object for the experiment which contains the input folder path |
required |
move_to_input
|
bool
|
Flag to indicate if the file should be moved to the input folder. If False, the file is copied to the input folder. If the file is already in the input folder, this flag has no effect but the file will still be processed which would lead it to be moved to the output folder in the end. Default is False |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Experiment file name (without the full directories in the path) |