fix: always left-pad inputs, and avoid optimizing for empty responses
Fixes #70 Co-authored-by: arnomatic <acc@eml.cc>
This commit is contained in:
@@ -37,6 +37,10 @@ class Evaluator:
|
||||
)
|
||||
|
||||
def is_refusal(self, response: str) -> bool:
|
||||
# Classify empty responses as refusals to avoid optimizing for them.
|
||||
if not response.strip():
|
||||
return True
|
||||
|
||||
# Remove emphasis (e.g. "I *will not*...").
|
||||
response = response.lower().replace("*", "")
|
||||
|
||||
|
||||
@@ -46,6 +46,10 @@ class Model:
|
||||
# Fallback for tokenizers that don't declare a special pad token.
|
||||
if self.tokenizer.pad_token is None:
|
||||
self.tokenizer.pad_token = self.tokenizer.eos_token
|
||||
|
||||
# CRITICAL: Always use left-padding for decoder-only models during generation.
|
||||
# Right-padding causes empty outputs because the model sees PAD tokens
|
||||
# after the prompt and thinks the sequence is complete.
|
||||
self.tokenizer.padding_side = "left"
|
||||
|
||||
self.model = None
|
||||
|
||||
Reference in New Issue
Block a user