langtest.transform.toxicity.ToxicityTestFactory#

class ToxicityTestFactory(data_handler: List[Sample], tests: Dict, **kwargs)#

Bases: ITests

A class for performing toxicity tests on a given dataset.

__init__(data_handler: List[Sample], tests: Dict, **kwargs) None#

Methods

__init__(data_handler, tests, **kwargs)

available_tests()

Get a dictionary of all available tests, with their names as keys and their corresponding classes as values.

run(sample_list, model, **kwargs)

Runs the specified tests on the given data and returns a list of results.

transform()

Runs the toxicity test and returns the resulting Sample objects.

Attributes

alias_name

static available_tests() dict#

Get a dictionary of all available tests, with their names as keys and their corresponding classes as values.

Returns:

A dictionary of test names and classes.

Return type:

dict

classmethod run(sample_list: Dict[str, List[Sample]], model: ModelAPI, **kwargs) List[Sample]#

Runs the specified tests on the given data and returns a list of results.

Parameters:
  • sample_list (Dict[str, List[Sample]]) – A dictionary mapping test scenario names to a list of Sample objects.

  • model (ModelAPI) – A ModelAPI object representing the model to be tested.

Returns:

A list of Sample objects with the test results.

Return type:

List[Sample]

transform() List[Sample]#

Runs the toxicity test and returns the resulting Sample objects.

Returns:

A list of Sample objects representing the resulting dataset after running the toxicity test.

Return type:

List[Sample]