-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from Health-Informatics-UoN/feature/LLMPipelin…
…eTest-class Feature/llm pipeline test class
- Loading branch information
Showing
3 changed files
with
90 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from typing import Dict | ||
from evaluation.evaltypes import ( | ||
SingleResultPipelineTest, | ||
SingleResultMetric, | ||
) | ||
from evaluation.pipelines import LLMPipeline | ||
|
||
|
||
class LLMPipelineTest(SingleResultPipelineTest): | ||
""" | ||
This class provides a pipeline test for LLM pipelines that return a single result | ||
""" | ||
|
||
def __init__( | ||
self, | ||
name: str, | ||
pipeline: LLMPipeline, | ||
metrics: list[SingleResultMetric], | ||
): | ||
""" | ||
Initialises the LLMPipelineTest class | ||
Parameters | ||
---------- | ||
name: str | ||
Name given to the test | ||
pipeline: LLMPipeline | ||
The pipeline used to generate output | ||
metrics: list[SingleResultMetric] | ||
A list of metrics used to compare the pipeline output with the expected output | ||
""" | ||
super().__init__(name, pipeline, metrics) | ||
|
||
def run_pipeline(self, input_data) -> str: | ||
""" | ||
Runs the provided pipeline on the input_data | ||
Parameters | ||
---------- | ||
input_data | ||
The data used for input to the pipeline | ||
Returns | ||
------- | ||
str | ||
The reply from the pipeline | ||
""" | ||
return super().run_pipeline(input_data) | ||
|
||
def evaluate(self, input_data, expected_output) -> Dict: | ||
""" | ||
Evaluates the attached pipeline's output against the expected output using the metrics | ||
Parameters | ||
---------- | ||
input_data | ||
The data used for input to the pipeline | ||
expected_output | ||
The expected result of running the input data through the pipeline | ||
Returns | ||
------- | ||
Dict | ||
A dictionary of results from evaluating the pipeline. | ||
""" | ||
return super().evaluate(input_data, expected_output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters