Benchmarks
Bases: ABC
This abstract class defines the structure for a benchmarking task. Subclasses of Benchmark must implement the 'run' method, which takes in various parameters related to the benchmarking task and returns a BenchmarkResult object.
Methods:
Name | Description |
---|---|
run |
Abstract method that must be implemented by subclasses. It runs the benchmarking task with the given parameters and returns a BenchmarkResult object. |
Source code in parsbench/benchmarks/base.py
6 7 8 9 10 11 12 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 |
|
run(prompt_lang='fa', prompt_shots=None, n_first=None, sort_by_score=True, save_matches=False, save_evaluation=False, save_benchmark=False, output_path=None, skip_existing_matches=False, prefer_concurrency=True, n_workers=4)
abstractmethod
Abstract method that must be implemented by subclasses. It runs the benchmarking task with the given parameters and returns a BenchmarkResult object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt_lang |
str
|
The language of the prompt (default is "fa"). |
'fa'
|
prompt_shots |
list[int]
|
The list of prompt shots to evaluate (default is None). |
None
|
n_first |
int
|
The number of initial prompts to consider (default is 200). |
None
|
sort_by_score |
bool
|
Whether to sort the model benchmarks by average score (default is True). |
True
|
save_matches |
bool
|
Flag to save the generated matches (default is False). |
False
|
save_evaluation |
bool
|
Flag to save the evaluation results (default is False). |
False
|
skip_existing_matches |
bool
|
Flag to skip already generated matches in the output path (default is False). |
False
|
output_path |
str
|
The output path to save the matches and evaluation results. |
None
|
prefer_concurrency |
bool
|
The flag to use concurrent processing if the model and task support that (default is True). |
True
|
n_workers |
int
|
The number of workers for concurrent processing (default is 4). |
4
|
Returns:
Name | Type | Description |
---|---|---|
BenchmarkResult |
BenchmarkResult
|
An object containing the benchmarking results. |
Source code in parsbench/benchmarks/base.py
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 |
|
Bases: Benchmark
CustomBenchmark class represents a custom benchmarking task that extends the Benchmark abstract class. It defines the run method to execute the benchmarking process for a given list of models and tasks.
Attributes:
Name | Type | Description |
---|---|---|
models |
list[Model]
|
The list of models to evaluate in the benchmarking task. |
tasks |
list[Task]
|
The list of tasks to evaluate with the models. |
Methods:
Name | Description |
---|---|
run |
Executes the benchmarking process for the specified models and tasks, generating evaluation results for each model on each task. |
Source code in parsbench/benchmarks/custom_benchmark.py
11 12 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
run(prompt_lang='fa', prompt_shots=None, n_first=None, sort_by_score=True, save_matches=False, save_evaluation=False, save_benchmark=False, output_path=None, skip_existing_matches=False, prefer_concurrency=True, n_workers=4)
Run the benchmarking process for the given models and tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt_lang |
str
|
The language of the prompt (default is "fa"). |
'fa'
|
prompt_shots |
list[int]
|
The list of prompt shots to evaluate (default is None). |
None
|
n_first |
int
|
The number of initial prompts to consider (default is 200). |
None
|
sort_by_score |
bool
|
Whether to sort the model benchmarks by average score (default is True). |
True
|
save_matches |
bool
|
Flag to save the generated matches (default is False). |
False
|
save_evaluation |
bool
|
Flag to save the evaluation results (default is False). |
False
|
output_path |
str
|
The output path to save the matches and evaluation results. |
None
|
skip_existing_matches |
bool
|
Flag to skip already generated matches in the output path (default is False). |
False
|
prefer_concurrency |
bool
|
The flag to use concurrent processing if the model and task support that (default is True). |
True
|
n_workers |
int
|
The number of workers for concurrent processing (default is 4). |
4
|
Returns:
Name | Type | Description |
---|---|---|
BenchmarkResult |
BenchmarkResult
|
The result of the benchmarking process. |
Source code in parsbench/benchmarks/custom_benchmark.py
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
Bases: CustomBenchmark
This benchmark class includes all existing tasks which use ParsiNLU datasets.
Attributes:
Name | Type | Description |
---|---|---|
models |
list[Model]
|
The list of models to evaluate in the benchmarking task. |
Methods:
Name | Description |
---|---|
run |
Executes the benchmarking process for the specified models, generating evaluation results for each model on each task. |
Source code in parsbench/benchmarks/parsinlu_benchmark.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
Represents the results of benchmarking a model across multiple evaluations.
Attributes:
Name | Type | Description |
---|---|---|
model_name |
str
|
The name of the model being benchmarked. |
evaluation_results |
list[EvaluationResult]
|
A list of EvaluationResult objects representing the evaluation results for the model. |
Source code in parsbench/benchmarks/benchmark_result.py
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 58 59 60 61 62 63 64 65 66 67 |
|
Represents the results of benchmarking multiple models across various evaluations.
Attributes:
Name | Type | Description |
---|---|---|
model_benchmarks |
list[ModelBenchmarkResult]
|
A list of ModelBenchmarkResult objects representing the benchmark results for each model. |
Source code in parsbench/benchmarks/benchmark_result.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
Merge multiple BenchmarkResult objects into a single BenchmarkResult object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
benchmarks |
list[BenchmarkResult]
|
A list of BenchmarkResult objects to merge. |
required |
sort |
bool
|
Whether to sort the merged ModelBenchmarkResult list by average score. Defaults to True. |
True
|
keep_duplicates |
bool
|
Whether to keep duplicate model names in the merged list. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
BenchmarkResult |
BenchmarkResult
|
A new BenchmarkResult object containing the merged ModelBenchmarkResult list. |
Source code in parsbench/benchmarks/benchmark_result.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
This function generates leaderboard data from the benchmark result object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
benchmark_result |
BenchmarkResult
|
BenchmarkResult object. |
required |
leaderboard_path |
str
|
Path to store the leaderboard data. |
required |
Source code in parsbench/benchmarks/benchmark_result.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
|