FlagOpen / FlagEmbedding

Retrieval and Retrieval-augmented LLMs
MIT License
6.59k stars 469 forks source link

can't load reranker-v2-minicpm-layerwise model #721

Open AlexYoung757 opened 4 months ago

AlexYoung757 commented 4 months ago

when uses code like this:

from FlagEmbedding import LayerWiseFlagLLMReranker

reranker = LayerWiseFlagLLMReranker('/path/bge-reranker-v2-minicpm-layerwise', use_fp16=True) 

score = reranker.compute_score(['query', 'passage'], cutoff_layers=[28]) # Adjusting 'cutoff_layers' to pick which layers are used for computing the score.
print(score)

environment

transformer==4.38.2 FlagEmbedding==1.2.9 sentence-transformers==2.6.1

so, the error as follow: Could not locate the configuration_minicpm_reranker.py inside BAAI/bge-reranker-v2-minicpm-layerwise.

OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like BAAI/bge-reranker-v2-minicpm-layerwise is not the path to a directory containing a file named configuration_minicpm_reranker.py. Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

But i have download the minicpm-layerwise model, and set the path. anyone have same question?

ChengRuiLiang commented 4 months ago

I had the same problem

545999961 commented 4 months ago

If you download reranker-v2-minicpm-layerwise, you can load it with the following method:

  1. make sure configuration_minicpm_reranker.py and modeling_minicpm_reranker.py in /path/bge-reranker-v2-minicpm-layerwise.
  2. modify the following part of config.json:
    "auto_map": {
    "AutoConfig": "configuration_minicpm_reranker.LayerWiseMiniCPMConfig",
    "AutoModel": "modeling_minicpm_reranker.LayerWiseMiniCPMModel",
    "AutoModelForCausalLM": "modeling_minicpm_reranker.LayerWiseMiniCPMForCausalLM"
    },
akkikiki commented 3 months ago

@545999961 Why are we turning off direct download from Huggingface in Commit https://github.com/FlagOpen/FlagEmbedding/commit/65cd70d73fc26dedbba5ceb1423b983cb7ee1c52? If we remove local_files_only=True then it works and having local file only seems quite inconvenient.

545999961 commented 3 months ago

@545999961 Why are we turning off direct download from Huggingface in Commit 65cd70d? If we remove local_files_only=True then it works and having local file only seems quite inconvenient.

I'm sorry that my negligence caused this problem, this part has been modified now, thank you for the reminder。

akkikiki commented 3 months ago

@545999961 Thanks a lot for the fix!

Zhouziyi828 commented 2 months ago

我现在还是会遇到这个问题,由于网络证书的原因我无法从huggingface上下载,所以我把他下载到了本地,但是报错信息显示他还是从huggingface下载上的,这怎么解决?

@545999961 Why are we turning off direct download from Huggingface in Commit 65cd70d? If we remove local_files_only=True then it works and having local file only seems quite inconvenient.

I'm sorry that my negligence caused this problem, this part has been modified now, thank you for the reminder。

我现在还是会遇到这个问题,由于网络证书的原因我无法从huggingface上下载,所以我把他下载到了本地,但是报错信息显示他还是从huggingface下载上的,这怎么解决?