|
63 | 63 | LoglikelihoodRequest,
|
64 | 64 | LoglikelihoodRollingRequest,
|
65 | 65 | )
|
66 |
| -from lighteval.utils import as_list |
| 66 | +from lighteval.utils import as_list, boolstring_to_bool |
67 | 67 | from lighteval.utils_parallelism import find_executable_batch_size
|
68 | 68 |
|
69 | 69 |
|
@@ -113,20 +113,10 @@ def __init__(
|
113 | 113 | # To implement PP parallelism we need to think about how we want to sync the output for the PP ranks without outputs
|
114 | 114 | raise ValueError("PP parallelism is not supported yet")
|
115 | 115 |
|
116 |
| - multichoice_continuations_start_space = lighteval_config.tasks.multichoice_continuations_start_space |
117 |
| - if ( |
118 |
| - not multichoice_continuations_start_space |
119 |
| - and not lighteval_config.tasks.no_multichoice_continuations_start_space |
120 |
| - ): |
121 |
| - multichoice_continuations_start_space = None |
122 |
| - # multichoice_continuations_start_space can be True (forcing space), False (forcing no space) or None (no forcing) |
123 |
| - if ( |
| 116 | + # multichoice_continuations_start_space can be True (forcing space), False (forcing no space) or None (no forcing) |
| 117 | + multichoice_continuations_start_space = boolstring_to_bool( |
124 | 118 | lighteval_config.tasks.multichoice_continuations_start_space
|
125 |
| - and lighteval_config.tasks.no_multichoice_continuations_start_space |
126 |
| - ): |
127 |
| - raise ValueError( |
128 |
| - "You cannot force both the multichoice continuations to start with a space and not to start with a space" |
129 |
| - ) |
| 119 | + ) |
130 | 120 |
|
131 | 121 | self.generation_config = lighteval_config.generation
|
132 | 122 | if isinstance(self.generation_config, dict):
|
@@ -409,10 +399,11 @@ def _check_continuations_start_space(self, continuation: str) -> str:
|
409 | 399 | - None (Don't touch - default)
|
410 | 400 | Todo: find a way to add this back WITHOUT breaking compatibility with the harness
|
411 | 401 | """
|
412 |
| - if self.multichoice_continuations_start_space is True and continuation[0] != " ": |
413 |
| - continuation = " " + continuation |
414 |
| - if self.multichoice_continuations_start_space is False and continuation[0] == " ": |
415 |
| - continuation = continuation.lstrip() |
| 402 | + if self.multichoice_continuations_start_space is not None: |
| 403 | + if self.multichoice_continuations_start_space and continuation[0] != " ": |
| 404 | + continuation = " " + continuation |
| 405 | + if not self.multichoice_continuations_start_space and continuation[0] == " ": |
| 406 | + continuation = continuation.lstrip() |
416 | 407 | return continuation
|
417 | 408 |
|
418 | 409 | def loglikelihood_single_token(
|
@@ -443,7 +434,7 @@ def loglikelihood_single_token(
|
443 | 434 | if any(len(c) > 1 for c in continuations_enc):
|
444 | 435 | raise ValueError(
|
445 | 436 | f"Trying to do single token multiple choice but one choice has several tokens: {continuations_enc}. "
|
446 |
| - "If the additional pre-token is a space, try to set --no_multichoice_continuations_start_space " |
| 437 | + "If the additional pre-token is a space, try to set multichoice_continuations_start_space=False in the model parameters " |
447 | 438 | )
|
448 | 439 | request.tokenized_continuation = continuations_enc
|
449 | 440 |
|
|
0 commit comments