| from sentence_transformers import SentenceTransformer | |
| from preprocess import meme_attribute, meme_filename, meme_list | |
| # This model supports two prompts: "s2p_query" and "s2s_query" for sentence-to-passage and sentence-to-sentence tasks, respectively. | |
| # They are defined in `config_sentence_transformers.json` | |
| # you can also use this model without the features of `use_memory_efficient_attention` and `unpad_inputs`. It can be worked in CPU. | |
| model = SentenceTransformer( | |
| "dunzhang/stella_en_400M_v5", | |
| trust_remote_code=True, | |
| device="cpu", | |
| config_kwargs={"use_memory_efficient_attention": False, "unpad_inputs": False} | |
| ) | |
| docs_list = list(meme_attribute.values()) | |
| doc_embeddings = model.encode(docs_list) | |
| embedded_dict = {key: embedding for key, embedding in zip(meme_attribute.keys(), doc_embeddings)} | |