dspy.Evaluate¶
dspy.Evaluate(*, devset: list[dspy.Example], metric: Callable | None = None, num_threads: int | None = None, display_progress: bool = False, display_table: bool | int = False, max_errors: int | None = None, provide_traceback: bool | None = None, failure_score: float = 0.0, save_as_csv: str | None = None, save_as_json: str | None = None, **kwargs)
¶
DSPy Evaluate class.
This class is used to evaluate the performance of a DSPy program. Users need to provide a evaluation dataset and a metric function in order to use this class. This class supports parallel evaluation on the provided dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
devset
|
list[Example]
|
the evaluation dataset. |
required |
metric
|
Callable
|
The metric function to use for evaluation. |
None
|
num_threads
|
Optional[int]
|
The number of threads to use for parallel evaluation. |
None
|
display_progress
|
bool
|
Whether to display progress during evaluation. |
False
|
display_table
|
Union[bool, int]
|
Whether to display the evaluation results in a table. If a number is passed, the evaluation results will be truncated to that number before displayed. |
False
|
max_errors
|
Optional[int]
|
The maximum number of errors to allow before
stopping evaluation. If |
None
|
provide_traceback
|
Optional[bool]
|
Whether to provide traceback information during evaluation. |
None
|
failure_score
|
float
|
The default score to use if evaluation fails due to an exception. |
0.0
|
save_as_csv
|
Optional[str]
|
The file name where the csv will be saved. |
None
|
save_as_json
|
Optional[str]
|
The file name where the json will be saved. |
None
|
Source code in dspy/evaluate/evaluate.py
Functions¶
__call__(program: dspy.Module, metric: Callable | None = None, devset: list[dspy.Example] | None = None, num_threads: int | None = None, display_progress: bool | None = None, display_table: bool | int | None = None, callback_metadata: dict[str, Any] | None = None, save_as_csv: str | None = None, save_as_json: str | None = None) -> EvaluationResult
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
program
|
Module
|
The DSPy program to evaluate. |
required |
metric
|
Callable
|
The metric function to use for evaluation. if not provided, use |
None
|
devset
|
list[Example]
|
the evaluation dataset. if not provided, use |
None
|
num_threads
|
Optional[int]
|
The number of threads to use for parallel evaluation. if not provided, use
|
None
|
display_progress
|
bool
|
Whether to display progress during evaluation. if not provided, use
|
None
|
display_table
|
Union[bool, int]
|
Whether to display the evaluation results in a table. if not provided, use
|
None
|
callback_metadata
|
dict
|
Metadata to be used for evaluate callback handlers. |
None
|
Returns:
Type | Description |
---|---|
EvaluationResult
|
The evaluation results are returned as a dspy.EvaluationResult object containing the following attributes: |
EvaluationResult
|
|
EvaluationResult
|
|
Source code in dspy/evaluate/evaluate.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
:::