From 8c9cfb0b689bce00b615b9557a9a767f286d7a33 Mon Sep 17 00:00:00 2001 From: Connor Boyle Date: Mon, 12 Jun 2023 01:38:42 -0700 Subject: [PATCH] Improve error for truncation with too high stride (#1275) --- tokenizers/src/tokenizer/encoding.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokenizers/src/tokenizer/encoding.rs b/tokenizers/src/tokenizer/encoding.rs index 40576efe..0693ad1e 100644 --- a/tokenizers/src/tokenizer/encoding.rs +++ b/tokenizers/src/tokenizer/encoding.rs @@ -316,7 +316,7 @@ impl Encoding { return; } - assert!(stride < max_len); + assert!(stride < max_len, "`stride` must be strictly less than `max_len={}` (note that `max_len` may be shorter than the max length of the original model, as it subtracts the number of special characters", max_len); // When truncating, we lose the `sequence_ranges` information. self.sequence_ranges.clear();