Fix truncation issue in classify_review function (#373)

This commit is contained in:
Sebastian Raschka
2024-09-25 19:54:36 -05:00
committed by GitHub
parent b8497c1bf5
commit 68505fab64
3 changed files with 5 additions and 3 deletions

View File

@@ -353,7 +353,7 @@ def classify_review(text, model, tokenizer, device, max_length=None, pad_token_i
# Prepare inputs to the model
input_ids = tokenizer.encode(text)
supported_context_length = model.pos_emb.weight.shape[1]
supported_context_length = model.pos_emb.weight.shape[0]
# Truncate sequences if they too long
input_ids = input_ids[:min(max_length, supported_context_length)]