"docs/vscode:/vscode.git/clone" did not exist on "da72ac6e260487c9e480d15592318c19a5227499"
Unverified Commit 7bac5183 authored by Bruno Alvisio's avatar Bruno Alvisio Committed by GitHub
Browse files

Pass parent exception as context exception to provide clearer stack trace (#21636)



* Pass parent exception as context exception to provide clearer stack trace

* Update src/transformers/tokenization_utils_base.py
Co-authored-by: default avatarSylvain Gugger <35901082+sgugger@users.noreply.github.com>

---------
Co-authored-by: default avatarSylvain Gugger <35901082+sgugger@users.noreply.github.com>
parent 3499c49c
......@@ -724,18 +724,18 @@ class BatchEncoding(UserDict):
# tensor = tensor[None, :]
self[key] = tensor
except: # noqa E722
except Exception as e:
if key == "overflowing_tokens":
raise ValueError(
"Unable to create tensor returning overflowing tokens of different lengths. "
"Please see if a fast version of this tokenizer is available to have this feature available."
)
) from e
raise ValueError(
"Unable to create tensor, you should probably activate truncation and/or padding with"
" 'padding=True' 'truncation=True' to have batched tensors with the same length. Perhaps your"
f" features (`{key}` in this case) have excessive nesting (inputs type `list` where type `int` is"
" expected)."
)
) from e
return self
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment