File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change 1515from llmtune .finetune .lora import LoRAFinetune
1616from llmtune .inference .lora import LoRAInference
1717from llmtune .pydantic_models .config_model import Config
18+ from llmtune .qa .generics import LLMTestSuite , QaTestRegistry
1819from llmtune .ui .rich_ui import RichUI
1920from llmtune .utils .ablation_utils import generate_permutations
2021from llmtune .utils .save_utils import DirectoryHelper
@@ -84,15 +85,13 @@ def run_one_experiment(config: Config, config_path: Path) -> None:
8485 else :
8586 RichUI .results_found (results_path )
8687
87- # QA -------------------------------
88- # RichUI.before_qa()
89- # qa_path = dir_helper.save_paths.qa
90- # if not exists(qa_path) or not listdir(qa_path):
91- # # TODO: Instantiate unit test classes
92- # # TODO: Load results.csv
93- # # TODO: Run Unit Tests
94- # # TODO: Save Unit Test Results
95- # pass
88+ RichUI .before_qa ()
89+ qa_file_path = dir_helper .save_paths .qa_file
90+ if not qa_file_path .exists ():
91+ llm_tests = config .qa .llm_tests
92+ tests = QaTestRegistry .create_tests_from_list (llm_tests )
93+ test_suite = LLMTestSuite .from_csv (results_file_path , tests )
94+ test_suite .save_test_results (qa_file_path )
9695
9796
9897@app .command ("run" )
Original file line number Diff line number Diff line change @@ -50,6 +50,14 @@ def __init__(
5050
5151 self .test_results = {}
5252
53+ @staticmethod
54+ def from_csv (file_path : str , tests : List [LLMQaTest ]) -> "LLMTestSuite" :
55+ results_df = pd .read_csv (file_path )
56+ prompts = results_df ["prompt" ].tolist ()
57+ ground_truths = results_df ["ground_truth" ].tolist ()
58+ model_preds = results_df ["model_prediction" ].tolist ()
59+ return LLMTestSuite (tests , prompts , ground_truths , model_preds )
60+
5361 def run_tests (self ) -> Dict [str , List [Union [float , int , bool ]]]:
5462 test_results = {}
5563 for test in zip (self .tests ):
You can’t perform that action at this time.
0 commit comments