Error in retrieving document 'SentenceTransformer' object has no attribute 'default_prompt_name'

234 Views Asked by At

I will retrieve the relevant documents from the given query, but why does the error appear as shown in the image?

image of running results

import joblib
loaded_db = joblib.load('/content/drive/MyDrive/Skripsi/Db/db_1000_100.joblib')
retriever = loaded_db.as_retriever()
query = "Apa saja jenis intervensi gizi?"
retriever = loaded_db.as_retriever()
retrieved_docs = retriever.get_relevant_documents(query)
retrieved_docs

the error display looks like this

AttributeError                            Traceback (most recent call last)
<ipython-input-11-efcb9fa990f2> in <cell line: 3>()
      1 query = "Apa saja jenis intervensi gizi?"
      2 retriever = loaded_db.as_retriever()
----> 3 retrieved_docs = retriever.get_relevant_documents(query)
      4 retrieved_docs

9 frames
/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py in __getattr__(self, name)
   1693             if name in modules:
   1694                 return modules[name]
-> 1695         raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
   1696 
   1697     def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -> None:

AttributeError: 'SentenceTransformer' object has no attribute 'default_prompt_name'

previously I was successful when running, but when I ran with the new runtime it got an error like this, I tried restarting the session and upgrading the sentence transformer, but the result was still an error, is there something wrong in my code?

1

There are 1 best solutions below

0
tommeke303 On

I had the same issue. You can solve this by downgrading the SentenceTransformers library. This issue is due to the new release of SentenceTransformers version 2.4.0. If you downgrade to 2.3.1 the issue is resolved.