Replies: 1 comment 1 reply
-
🤖 It looks like you're encountering an error related to padding while using the Hugging Face model. The error message suggests that the tokenizer does not have a padding token defined. To address this issue, you can add a new pad token to the tokenizer by using the following code: tokenizer.add_special_tokens({'pad_token': '[PAD]'}) You can uncomment the line Once you make this change, you can try running the code again to see if the issue is resolved. If you encounter any further challenges, feel free to ask for assistance. And if you have a proposed solution or fix, consider contributing it to the LlamaIndex by creating a pull request. Your contributions are valuable to the community! This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
code:
`hf_model_name = 'StabilityAI/stablelm-tuned-alpha-3b'
tokenizer_kwargs = {'padding':'longest',"max_length": 4096}
tokenizer = AutoTokenizer.from_pretrained(hf_model_name,**tokenizer_kwargs)
if tokenizer.pad_token is None:
tokenizer.add_special_tokens({'pad_token': '[PAD]'})
#tokenizer.add_special_tokens({'pad_token': '[PAD]'})
#tokenizer.pad_token = tokenizer.eos_token
#print(tokenizer)
set_global_tokenizer(tokenizer.encode)
llm = HuggingFaceLLM(model_name=hf_model_name,
tokenizer_name=hf_model_name,
tokenizer = tokenizer,
context_window=4096,
max_new_tokens=512,
generate_kwargs={"temperature": 0.8, "do_sample": True, "top_p":0.95, "top_k":20},
device_map="auto",
#stopping_ids=[50278, 50279, 50277, 1, 0],
model_kwargs={"trust_remote_code" : True},
#tokenizer_kwargs=tokenizer_kwargs,
# uncomment this if using CUDA to reduce memory usage
#model_kwargs={"torch_dtype": torch.float16, "trust_remote_code" :True}
)`
alueError: Asking to pad but the tokenizer does not have a padding token. Please select a token to use as
pad_token
(tokenizer.pad_token = tokenizer.eos_token e.g.)
or add a new pad token viatokenizer.add_special_tokens({'pad_token': '[PAD]'})
.Beta Was this translation helpful? Give feedback.
All reactions