I am trying to load embeddings like this.I changed the code to reflect the current version change in LlamaIndex but it shows up an attribute error.
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.core import Settings
Settings.embed_model = HuggingFaceEmbedding(
model_name="BAAI/bge-small-en-v1.5"
)
AttributeError: module 'torch._subclasses' has no attribute 'functional_tensor'
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/transformers/utils/import_utils.py in _get_module(self, module_name) 1364 return importlib.import_module("." + module_name, self.name) 1365 except Exception as e: -> 1366 raise RuntimeError( 1367 f"Failed to import {self.name}.{module_name} because of the following error (look up to see its" 1368 f" traceback):\n{e}"
RuntimeError: Failed to import transformers.models.bert.modeling_bert because of the following error (look up to see its traceback): module 'torch._subclasses' has no attribute 'functional_tensor'
This is happening when I am trying to load the reranker as well.
from llama_index.core.postprocessor import SentenceTransformerRerank
rerank = SentenceTransformerRerank(
model="cross-encoder/ms-marco-MiniLM-L-12-v2", top_n=3
)
I tried to upgrade the libraries and reinstalling llama index but its not working.
!pip uninstall llama-index !pip install llama-index --upgrade --no-cache-dir --force-reinstall
!pip install --upgrade torch !pip install --upgrade transformers
I am running this on Google Colab. Thank you if you help in this.