princeton-nlp / SimCSE

[EMNLP 2021] SimCSE: Simple Contrastive Learning of Sentence Embeddings https://arxiv.org/abs/2104.08821
MIT License
3.31k stars 502 forks source link

TypeError: object of type 'IndexFlatIP' has no len() #268

Closed Maydaytyh closed 4 months ago

Maydaytyh commented 6 months ago

Hi, I trained roberta-large with my own data by using run_sup_example.sh. But when I build index for senteced and use model.search, I encountered the error. The building process has no problem, the error is in model.search.

/site-packages/simcse/tool.py", line 64, in encode
    total_batch = len(sentence) // batch_size + (1 if len(sentence) % batch_size > 0 else 0)
TypeError: object of type 'IndexFlatIP' has no len()
Maydaytyh commented 6 months ago

I modify the default value of use_faiss to True, then it works. Maybe something wrong

gaotianyu1350 commented 6 months ago

Hi Maydaytyh,

Thanks for spotting our the problem! I'll look into it

github-actions[bot] commented 5 months ago

Stale issue message

github-actions[bot] commented 4 months ago

Stale issue message