BaseMetric¶
gaico.metrics.base.BaseMetric ¶
Bases: ABC
Abstract base class for all language model metrics.
This class defines the interface that all metric classes should implement.
The public method to be accessed is calculate
.
calculate ¶
calculate(generated, reference, **kwargs)
Calculates the metric for a single or batch of generated and reference items. This method handles both single and batch inputs.
If the reference is None and generated
is an iterable, the function will assume the first element of the iterable as the reference. A warning will be printed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
generated
|
Any
|
A single generated item or an iterable of generated items. Must not be None. |
required |
reference
|
Optional[Any]
|
A single reference item, an iterable of reference items, or None. |
required |
kwargs
|
Any
|
Additional keyword arguments for specific metrics. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The calculated metric score(s). |
Raises:
Type | Description |
---|---|
ValueError
|
If |
TypeError
|
If inputs cannot be converted to suitable iterables. |