list out of range when using embeddings

Viewed 47

I have the following list:

list1=[['brute-force',
  'password-guessing',
  'password-guessing',
  'default-credentials',
  'shell'],
 ['malware',
  'ddos',
  'phishing',
  'spam',
  'botnet',
  'cryptojacking',
  'xss',
  'sqli',
  'vulnerability'],
 ['sensitive-information']]

I am trying the example from here enter link description here

However when I am fitting my list to get the embeddings :

embeddings1 =sbert_model.encode(list1, convert_to_tensor=True)

I get the embeding i get the following error:

IndexError                                Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_16484/3954167634.py in <module>
----> 1 embeddings2 = sbert_model.encode(list3, convert_to_tensor=True)

~\anaconda3\envs\tensorflow_env\lib\site-packages\sentence_transformers\SentenceTransformer.py in encode(self, sentences, batch_size, show_progress_bar, output_value, convert_to_numpy, convert_to_tensor, device, normalize_embeddings)
    159         for start_index in trange(0, len(sentences), batch_size, desc="Batches", disable=not show_progress_bar):
    160             sentences_batch = sentences_sorted[start_index:start_index+batch_size]
--> 161             features = self.tokenize(sentences_batch)
    162             features = batch_to_device(features, device)
    163 

~\anaconda3\envs\tensorflow_env\lib\site-packages\sentence_transformers\SentenceTransformer.py in tokenize(self, texts)
    317         Tokenizes the texts
    318         """
--> 319         return self._first_module().tokenize(texts)
    320 
    321     def get_sentence_features(self, *features):

~\anaconda3\envs\tensorflow_env\lib\site-packages\sentence_transformers\models\Transformer.py in tokenize(self, texts)
    101             for text_tuple in texts:
    102                 batch1.append(text_tuple[0])
--> 103                 batch2.append(text_tuple[1])
    104             to_tokenize = [batch1, batch2]
    105 

IndexError: list index out of range

I am understanding how lists work and I have read many asnwers to same problem in here but i cannot fiqure out why is going out of range.

Any ideas?

0 Answers
Related