Skip to content

vllm.tokenizers.hf

Classes:

Functions:

ThreadSafeHFTokenizerMixin

Mixin class for thread-safe HF fast tokenizers.

encode_with_special_tokens_mask(tokenizer, text, **kwargs)

Encode text with a best-effort mask of tokenizer-added special tokens.

get_cached_tokenizer(tokenizer)

By default, transformers will recompute multiple tokenizer properties each time they are called, leading to a significant slowdown. This proxy caches these properties for faster access.

maybe_make_thread_pool(tokenizer, copies=1)

If tokenizer is a TokenizersBackend, modify the tokenizer in-place to make the public interface thread-safe by routing calls through a deep-copied tokenizer pool.

Note that: - Only TokenizerLike's public interface is thread-safe. This doesn't include _tokenizer property nor any mutation methods like add_special_tokens or add_tokens. - Adjacent method calls could happen on different deep copies.