Tasks
Bases: TaskMatchGenerator
, TaskScorer
Task class represents a task that combines functionality from TaskMatchGenerator and TaskScorer.
Attributes:
Name | Type | Description |
---|---|---|
task_name |
str
|
The name of the task. |
task_category |
TaskCategory
|
The category of the task. |
Methods:
Name | Description |
---|---|
evaluate |
Method to evaluate the task by generating matches, scoring them, and saving the results. |
Source code in parsbench/tasks/base/task.py
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 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
evaluate(model, prompt_lang='fa', prompt_shots=None, n_first=200, sub_tasks=None, save_matches=False, save_evaluation=False, output_path=None, skip_existing_matches=False, prefer_concurrency=True, n_workers=4)
Method to evaluate the task by generating matches, scoring them, and saving the results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
Model
|
The model to be evaluated. |
required |
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). |
200
|
sub_tasks |
list[str]
|
The list of sub-tasks to evaluate (default is None). |
None
|
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:
Type | Description |
---|---|
list[EvaluationResult]
|
list[EvaluationResult]: A list of EvaluationResult objects representing the evaluation results. |
Raises:
Type | Description |
---|---|
Exception
|
If output_path is not provided when saving matches or evaluation. |
Exception
|
If output_path is not provided when skipping existing matches. |
Exception
|
If sub tasks are not defined or if invalid sub tasks are provided. |
Source code in parsbench/tasks/base/task.py
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 262 263 264 265 266 267 268 269 270 271 |
|
Bases: ABC
An abstract base class for defining data loaders.
Attributes:
Name | Type | Description |
---|---|---|
data_path |
str
|
The path to the data source. |
Methods:
Name | Description |
---|---|
load |
Abstract method to be implemented by subclasses for loading data. |
Source code in parsbench/tasks/base/data_loader.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
Bases: DataLoader
A data loader class for loading JSON line data from either a local file or a URL.
Attributes:
Name | Type | Description |
---|---|---|
data_path |
str
|
The path to the JSON line data source. |
Methods:
Name | Description |
---|---|
load |
Loads the JSON line data from the specified source. |
Source code in parsbench/tasks/base/data_loader.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
Bases: DataLoader
A data loader class for loading datasets using the Hugging Face library.
Attributes:
Name | Type | Description |
---|---|---|
data_path |
str
|
The path to the data source. |
split |
str | None
|
The split of the dataset to load. |
Methods:
Name | Description |
---|---|
load |
Loads the dataset from the specified data path and split. |
with_filter |
Callable[..., bool]) -> "HuggingFaceDataLoader": Adds a filter function to apply when loading the dataset. |
Source code in parsbench/tasks/base/data_loader.py
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 |
|
Bases: DataLoader
A data loader class for loading CSV line data from either a local file or a URL.
Attributes:
Name | Type | Description |
---|---|---|
data_path |
str
|
The path to the CSV line data source. |
Methods:
Name | Description |
---|---|
load |
Loads the CSV line data from the specified source. |
Source code in parsbench/tasks/base/data_loader.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
A class representing a prompt template.
Attributes:
Name | Type | Description |
---|---|---|
language_templates |
dict[str, str]
|
A dictionary mapping language codes to prompt templates. |
prompt_variables_mapping |
dict[str, str]
|
A dictionary mapping prompt variable names to corresponding data keys. |
target_variables_mapping |
dict[str, str]
|
A dictionary mapping target variable names to corresponding data keys. |
prompt_shot_templates |
dict[str, str] | None
|
A dictionary mapping prompt shot templates to language codes, or None if not provided. |
prompt_shot_examples |
dict[str, dict[int, str]] | None
|
A dictionary mapping prompt shot examples to language codes and shot numbers, or None if not provided. |
Source code in parsbench/tasks/base/prompt_template.py
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 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 |
|
Bases: Mapping
A class representing lazy loading of templates.
Inherits from Mapping.
Attributes:
Name | Type | Description |
---|---|---|
template_paths |
dict[str, str]
|
A dictionary mapping template keys to file paths. |
Source code in parsbench/tasks/base/prompt_template.py
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 |
|
A data class representing the evaluation result for a prompt shot, including the number of shots and the corresponding score.
Attributes:
Name | Type | Description |
---|---|---|
n_shots |
int
|
The number of shots for the evaluation. |
score |
float
|
The score obtained for the prompt shot evaluation. |
Source code in parsbench/tasks/base/evaluation_result.py
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 |
|
A data class representing the evaluation result for a model on a specific task, including the model name, task name, task category, score name, prompt shot results, and optional sub-task.
Attributes:
Name | Type | Description |
---|---|---|
model_name |
str
|
The name of the model being evaluated. |
task_name |
str
|
The name of the task for which the model is being evaluated. |
task_category |
TaskCategory
|
The category of the task (e.g., CLASSIC, REASONING, MATH, KNOWLEDGE). |
score_name |
str
|
The name of the score obtained for the evaluation. |
prompt_shot_results |
list[PromptShotEvaluationResult]
|
A list of PromptShotEvaluationResult objects representing the evaluation results for prompt shots. |
sub_task |
str
|
The name of the sub-task being evaluated, if applicable. |
Source code in parsbench/tasks/base/evaluation_result.py
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 112 113 114 115 116 117 118 119 120 121 122 |
|
Source code in parsbench/tasks/base/task_match.py
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 |
|
Source code in parsbench/tasks/base/task_match.py
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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
Load all tasks from the 'parsbench.tasks' package and return a list of Task objects.
Returns:
Type | Description |
---|---|
list[Task]
|
list[Task]: A list of Task objects representing all tasks found in the 'parsbench.tasks' package. |
Source code in parsbench/tasks/utils.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|