0

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.

2 Answers 2

0

Check for your torch version !python -c "import torch; print(torch.version)"

Downgrading it works

!python -m pip install --upgrade torch==1.13.0

Sign up to request clarification or add additional context in comments.

Comments

0

you will have to install llama-index-embeddings-huggingface as well .

Try next command:

pip install llama-index-embeddings-huggingface

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.