What shoud I do if an LLM model in huggingface transformers do not have a pad_token in…
- User
What shoud I do if an LLM model in huggingface transformers do not have a pad_token in its tokenizer, but I need to do batch inference?
- Assistant
If an LLM model in Hugging Face Transformers does not have a
pad_tokendefined in its tokenizer, but you need to perform batch inference, you can manually define a padding token and update the tokenizer accordingly. Here's how you can do it:-
Choose a token to use as the padding token. It should be a token that is not commonly used in your input sequences. For example, you can use a special token like
[PAD]or<pad>. -
Add the padding token to the tokenizer's vocabulary:
pythontokenizer.add_special_tokens({'pad_token': '[PAD]'})Replace
'[PAD]'with the padding token of your choice.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.