lm_polygraph.utils.common module

lm_polygraph.utils.common.flatten_results(results, result_generator_class)[source]

Flattens a list of lists into a single list. Сan be used with any type of result, such as UEs, statistics, or generation metrics.

Args:
results: A list of lists, where each sublist contains results for a single input.

Expected shape: [num_inputs, num_token_level_results_per_input].

result_generator_class: The class of the object that generated the results.

Used for error reporting.

Returns:

A flattened list of results of shape [num_inputs * num_token_level_results_per_input].

Raises:

Exception: If the input is not a list of lists.

lm_polygraph.utils.common.load_external_module(path_to_file: str)[source]

Load external module from file and return it.

lm_polygraph.utils.common.load_image(image_path)[source]
lm_polygraph.utils.common.load_processor(model_path, **kwargs)[source]
lm_polygraph.utils.common.polygraph_module_init(func)[source]
lm_polygraph.utils.common.seq_man_key(metric_name: str) Tuple[str, str][source]

Convert metric name to format of seq-level name format of saved manager archive.