Skip to content

Commit

Permalink
Merge pull request #129 from MLDSAI/fix/prompt_truncation
Browse files Browse the repository at this point in the history
fix prompt truncation; fix diff_mask
  • Loading branch information
abrichr authored May 9, 2023
2 parents 4f22e89 + dd045ef commit 0ab8213
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion puterbot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def diff(self):
@property
def diff_mask(self):
if not self._diff_mask:
self._diff_mask = self._diff.convert("1")
self._diff_mask = self.diff.convert("1")
return self._diff_mask

@property
Expand Down
6 changes: 5 additions & 1 deletion puterbot/strategies/llm_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ def get_completion(
logger.warning(
f"Truncating from {len(prompt)=} to {max_input_size=}"
)
prompt = prompt[max_input_size:]
prompt = prompt[-max_input_size:]
logger.warning(
f"Truncated {len(prompt)=}"
)

logger.debug(f"{prompt=} {max_tokens=}")
input_tokens = self.tokenizer(prompt, return_tensors="pt")
pad_token_id = self.tokenizer.eos_token_id
Expand Down

0 comments on commit 0ab8213

Please sign in to comment.