This commit is contained in:
ydshieh 2024-12-17 16:14:37 +01:00
parent db865dbeda
commit bf14c4b95a

View file

@ -1503,17 +1503,6 @@ class Kosmos2_5TextTransformer(nn.Module):
hidden_states = nn.functional.dropout(hidden_states, p=self.dropout, training=self.training)
return_legacy_cache = False
if (
use_cache and not isinstance(past_key_values, Cache) and not self.training
): # kept for BC (non `Cache` `past_key_values` inputs)
return_legacy_cache = True
past_key_values = DynamicCache.from_legacy_cache(past_key_values)
logger.warning_once(
"We detected that you are passing `past_key_values` as a tuple and this is deprecated and will be removed in v4.43. "
"Please use an appropriate `Cache` class (https://huggingface.co/docs/transformers/v4.41.3/en/internal/generation_utils#transformers.Cache)"
)
if cache_position is None:
past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
cache_position = torch.arange(