Skip to content

Commit

Permalink
fixed bug no set max_length and special token
Browse files Browse the repository at this point in the history
  • Loading branch information
JingofXin committed Sep 11, 2024
1 parent 30bd933 commit b1d1bb0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lazyllm/components/embedding/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def load_embed(self):

def __call__(self, string):
lazyllm.call_once(self.init_flag, self.load_embed)
encoded_input = self.tokenizer(string, padding=True, truncation=True, return_tensors='pt').to(self.device)
encoded_input = self.tokenizer(string, padding=True, truncation=True, return_tensors='pt',
max_length=512, add_special_tokens=True).to(self.device)
with torch.no_grad():
model_output = self.embed(**encoded_input)
sentence_embeddings = model_output[0][:, 0]
Expand Down

0 comments on commit b1d1bb0

Please sign in to comment.