Open 1ndiecowan opened 3 months ago
Hello!
Upon further investigation, I found that the issue seems to be that the local variable 'prompt' is not available inside the scope of the list comprehension that adds the prompt to the beginning of each of the sentences. This can easily be fixed by using an f string inside the comprehension instead of concatenation for some reason. This seems like a silly feature of python to me...
I'm unable to reproduce this exactly. If prompt
was not defined/accessible, then we would get a different error. This is seeming like prompt
is somehow a bool rather than the prompt string, e.g. you may have:
prompt=True
to model.encode
prompts={"clustering": True}
as a dictionary with string keys and bool valuesOr something like that. Could you try and reply with a reproducible example? E.g. like:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer(
"all-MiniLM-L6-v2",
prompts={
"retrieval": "Retrieve documents that are similar to: ",
},
default_prompt_name="retrieval",
)
sentence = "The quick brown fox jumps over the lazy dog."
embedding = model.encode(sentence)
print(embedding.shape)
# => (384,)
When I try to use a prompt, I get this error: can only concatenate str (not "bool") to str. Upon further investigation, I found that the issue seems to be that the local variable 'prompt' is not available inside the scope of the list comprehension that adds the prompt to the beginning of each of the sentences. This can easily be fixed by using an f string inside the comprehension instead of concatenation for some reason. This seems like a silly feature of python to me...