Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
b72752f0
"docs/source/en/run_scripts.md" did not exist on "8d1f9039d01f79bfef763dd349d9904c13550c9d"
Unverified
Commit
b72752f0
authored
Jun 05, 2024
by
Dhaivat Bhatt
Committed by
GitHub
Jun 05, 2024
Browse files
Fix circular reference issue in CLIPTokenizerFast (#31075)
parent
464d986b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
src/transformers/models/clip/tokenization_clip_fast.py
src/transformers/models/clip/tokenization_clip_fast.py
+5
-2
No files found.
src/transformers/models/clip/tokenization_clip_fast.py
View file @
b72752f0
...
...
@@ -89,16 +89,19 @@ class CLIPTokenizerFast(PreTrainedTokenizerFast):
" to use your existing tokenizer, you will have to revert to a version prior to 4.17.0 of"
" transformers."
)
self
.
_wrap_decode_method_backend_tokenizer
()
# Very ugly hack to enable padding to have a correct decoding see https://github.com/huggingface/tokenizers/issues/872
def
_wrap_decode_method_backend_tokenizer
(
self
):
orig_decode_method
=
self
.
backend_tokenizer
.
decode
## define this as a local variable to avoid circular reference
## See: https://github.com/huggingface/transformers/issues/30930
end_of_word_suffix
=
self
.
backend_tokenizer
.
model
.
end_of_word_suffix
def
new_decode_method
(
*
args
,
**
kwargs
):
text
=
orig_decode_method
(
*
args
,
**
kwargs
)
text
=
text
.
replace
(
self
.
backend_tokenizer
.
model
.
end_of_word_suffix
,
" "
).
strip
()
text
=
text
.
replace
(
end_of_word_suffix
,
" "
).
strip
()
return
text
self
.
backend_tokenizer
.
decode
=
new_decode_method
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment