从 Llama Index 中加载 Hugging Face 嵌入模型会引发属性错误

问题描述 投票:0回答:1

我正在尝试加载这样的嵌入。我更改了代码以反映 LlamaIndex 中的当前版本更改,但它显示了属性错误。

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:模块“torch._subclasses”没有属性“function_tensor”

上述异常是导致以下异常的直接原因:

运行时错误回溯(最近一次调用最后)

/usr/local/lib/python3.10/dist-packages/transformers/utils/import_utils.py 在 _get_module(self, module_name) 第1364章 第1365章 1365 -> 1366 引发运行时错误( 第1367章 1368 f" 回溯): {e}” 运行时错误:由于以下错误,无法导入transformers.models.bert.modeling_bert(查找其回溯): 模块“torch._subclasses”没有属性“function_tensor” 当我尝试加载重新排序器时也会发生这种情况。

from llama_index.core.postprocessor import SentenceTransformerRerank rerank = SentenceTransformerRerank( model="cross-encoder/ms-marco-MiniLM-L-12-v2", top_n=3 )

我尝试升级库并重新安装 llama 索引,但它不起作用。

!pip 卸载 llama-index
!pip install llama-index --upgrade --no-cache-dir --force-reinstall

!pip install --升级 torch !pip install --升级变压器

我正在 Google Colab 上运行这个。 如果您对此有所帮助,谢谢。

检查您的手电筒版本 !python -c“导入火炬;打印(火炬。

版本
google-colaboratory huggingface-transformers llama-index llama-cpp-python
1个回答
0
投票

降级它有效 !python -m pip install --升级torch==1.13.0

© www.soinside.com 2019 - 2024. All rights reserved.