Base
Base classes for defining RAG evaluation metrics.
Metric
dataclass
Bases: ABC
Abstract base class for evaluation metrics.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Name of the metric. |
Source code in ragbot\evaluation\metrics\base.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
required_columns
property
writable
Set of columns required in the input sample to compute the metric.
Returns:
| Type | Description |
|---|---|
Set[str]
|
Set[str]: Required column names. |
init()
Optional initializer hook for the metric.
Source code in ragbot\evaluation\metrics\base.py
24 25 26 | |
score(sample, **kwargs)
abstractmethod
Compute a score for a given sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
Sample
|
Input data to evaluate. |
required |
**kwargs
|
Any
|
Additional arguments (e.g., for callbacks or config). |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Computed metric score. |
Source code in ragbot\evaluation\metrics\base.py
46 47 48 49 50 51 52 53 54 55 56 57 | |
MetricWithEmbeddings
dataclass
Bases: Metric, ABC
Base class for metrics that require embeddings to operate.
Source code in ragbot\evaluation\metrics\base.py
71 72 73 74 75 76 77 78 79 | |
init()
Check that embeddings are set before scoring.
Source code in ragbot\evaluation\metrics\base.py
76 77 78 79 | |
MetricWithLLM
dataclass
Bases: Metric, ABC
Base class for metrics that require an LLM to operate.
Source code in ragbot\evaluation\metrics\base.py
60 61 62 63 64 65 66 67 68 | |
init()
Check that the LLM is set before scoring.
Source code in ragbot\evaluation\metrics\base.py
65 66 67 68 | |