You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am trying to use the GPT-Neo model from Hugging Face library to generate the sentence embedding using the Sentence Transformer Library.
from sentence-transformer import SentenceTransformer
gpt = SentenceTransformer('EleutherAI/gpt-neo-1.3B')
embeddings = gpt.encode(['This is example of using GPT'])
For the above code for generating the sentence embeddings, it is giving the following error. ValueError: 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 via `tokenizer.add_special_tokens({'pad_token': '[PAD]'})
As far as I can, I didnot find any way to add tokenizer with special token as required using the sentence-transformer library. Can anyone please help me with this error.
The issue has been solved initiating the tokenizer before using for embedding generation.
modified code :
from sentence_transformers import SentenceTransformer
gpt = SentenceTransformer('EleutherAI/gpt-neo-1.3B')
gpt.tokenizer.pad_token = gpt.tokenizer.eos_token
embeddings = gpt.encode(['This is example of using GPT']
Hi,
I am trying to use the GPT-Neo model from Hugging Face library to generate the sentence embedding using the Sentence Transformer Library.
For the above code for generating the sentence embeddings, it is giving the following error.
ValueError: 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 via `tokenizer.add_special_tokens({'pad_token': '[PAD]'})As far as I can, I didnot find any way to add tokenizer with special token as required using the sentence-transformer library. Can anyone please help me with this error.
Environment :
python - 3.8
sentence-transformer - 2.0.0
transformers - 4.11.1
The text was updated successfully, but these errors were encountered: