Skip to content

Commit

Permalink
fix for null past_key_values, getting supported tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahyklee committed Oct 24, 2023
1 parent 17cd546 commit e104a0a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions open_flamingo/eval/eval_models/eval_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def supported_tasks(self):
Parsed by checking whether the model has a method called `get_{task}_prompt`.
"""
return [
task.split("_")[1]
"_".join(task.split("_")[1:-1])
for task in dir(self)
if task.startswith("get_") and task.endswith("_prompt")
]
Expand All @@ -207,4 +207,4 @@ def _validate_text(self, batch_text):
if any([x.endswith(" ") for x in batch_text]):
print(
"Warning: trailing whitespace detected in text. This can cause unexpected behavior."
)
)
15 changes: 8 additions & 7 deletions open_flamingo/src/vlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,14 @@ def _prepare_inputs_for_forward(
past_vision_tokens=past_vision_tokens,
num_beams=num_beams,
)
past_key_values = [
(
k.repeat_interleave(num_beams, dim=0),
v.repeat_interleave(num_beams, dim=0)
)
for k, v in past_key_values
]
if past_key_values is not None:
past_key_values = [
(
k.repeat_interleave(num_beams, dim=0),
v.repeat_interleave(num_beams, dim=0)
)
for k, v in past_key_values
]
return {
"input_ids": lang_x,
"attention_mask": attention_mask,
Expand Down

0 comments on commit e104a0a

Please sign in to comment.