Benchmarking
benchmark_sampling(llm: AutoregressiveSampler, system_message: str, question_list: list[str], answer_list: list[str], enable_thinking: bool, chat_template: bool, sampling_techniques: list[bool], max_questions: int = 0, output_file_name: str = 'math500_power_sampling_results.csv', **kwargs: Any) -> None
Benchmark different sampling techniques on a dataset of math problems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
llm
|
AutoregressiveSampler
|
The AutoregressiveSampler instance to use for generation. |
required |
system_message
|
str
|
The system message to include in prompts. |
required |
question_list
|
list[str]
|
List of formatted questions to benchmark. |
required |
answer_list
|
list[str]
|
List of correct answers corresponding to the questions. |
required |
enable_thinking
|
bool
|
Whether to enable thinking mode in chat templates. |
required |
chat_template
|
bool
|
Whether to use chat template formatting for prompts. |
required |
sampling_techniques
|
list[bool]
|
List of booleans indicating which sampling techniques to use. [0]: Naive sampling (temperature=1.0) [1]: Low temperature sampling [2]: Power sampling (MCMC) |
required |
max_questions
|
int
|
Maximum number of questions to process. 0 means process all. |
0
|
output_file_name
|
str
|
Path to the output CSV file for results. |
'math500_power_sampling_results.csv'
|
**kwargs
|
Any
|
Additional keyword arguments passed to sampling functions. log_file_path: Base directory for logging individual question results. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None. Results are written to the output CSV file. |
Source code in pita/utils/benchmarking_utils.py
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 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
format_dataset(dataset: datasets.Dataset, pre_question: str, post_question: str) -> tuple[list[str], list[str]]
Format a dataset by adding pre and post question templates to each problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
The dataset containing problems and answers. |
required |
pre_question
|
str
|
Text to prepend before each problem. |
required |
post_question
|
str
|
Text to append after each problem. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
A tuple of (question_list, answer_list) where question_list contains |
list[str]
|
formatted questions and answer_list contains corresponding answers. |
Source code in pita/utils/benchmarking_utils.py
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 | |
load_benchmark(dataset_name: str) -> tuple[str, list[str], list[str]]
Load a benchmark dataset by name and return formatted questions and answers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_name
|
str
|
Name of the dataset to load. Supported values are "MATH500" and "AIME". |
required |
Returns:
| Type | Description |
|---|---|
str
|
A tuple of (system_message, question_list, answer_list) where: |
list[str]
|
|
list[str]
|
|
tuple[str, list[str], list[str]]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the dataset_name is not supported. |
Source code in pita/utils/benchmarking_utils.py
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 | |
tokenizer_chat_template(tokenizer: AutoTokenizer, enable_thinking: bool, system_message: str, user_message: str) -> str
Format messages for chat models using the tokenizer's chat template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tokenizer
|
AutoTokenizer
|
The AutoTokenizer instance to use for formatting. |
required |
enable_thinking
|
bool
|
Whether to enable thinking mode in the chat template. |
required |
system_message
|
str
|
The system message content to include. |
required |
user_message
|
str
|
The user message content to include. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The formatted prompt string ready for the model. |
Source code in pita/utils/benchmarking_utils.py
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 | |