Update modeling_minicpm.py for compatibility with transformers 4.49
#4
by
sylwia-kuros
- opened
- modeling_minicpm.py +1 -1
modeling_minicpm.py
CHANGED
@@ -1246,7 +1246,7 @@ class MiniCPMForCausalLM(MiniCPMPreTrainedModel):
|
|
1246 |
if isinstance(past_key_values, Cache):
|
1247 |
cache_length = past_key_values.get_seq_length()
|
1248 |
past_length = past_key_values.seen_tokens
|
1249 |
-
max_cache_length = past_key_values.get_max_length()
|
1250 |
else:
|
1251 |
cache_length = past_length = past_key_values[0][0].shape[2]
|
1252 |
max_cache_length = None
|
|
|
1246 |
if isinstance(past_key_values, Cache):
|
1247 |
cache_length = past_key_values.get_seq_length()
|
1248 |
past_length = past_key_values.seen_tokens
|
1249 |
+
max_cache_length = past_key_values.get_max_length() if hasattr(past_key_values, "get_max_length") else past_key_values.get_max_cache_shape()
|
1250 |
else:
|
1251 |
cache_length = past_length = past_key_values[0][0].shape[2]
|
1252 |
max_cache_length = None
|