fastembed
fastembed copied to clipboard
[Bug]: Unable to download any models from HF
What happened?
This is the error trace
Invalid credentials in Authorization header Falling back to other sources.
2025-03-14 11:08:19.111 | ERROR | fastembed.common.model_management:download_model:450 - Could not download model from either source, sleeping for 9.0 seconds, 1 retries left.
2025-03-14 11:08:28.205 | ERROR | fastembed.common.model_management:download_model:429 - Could not download model from HuggingFace: 401 Client Error: Unauthorized for url: https://huggingface.co/api/models/Qdrant/SPLADE_PP_en_v1 (Request ID: Root=1-67d40e2c-7540f5184c06df970fa49cd8;e1d630bf-29d9-498f-aa7f-b43ab6f105ca)
However, the API call via browser works just fine
What is the expected behaviour?
That it downloads
A minimal reproducible example
from qdrant_client import QdrantClient, models
class DB:
DENSE_MODEL = "sentence-transformers/all-MiniLM-L6-v2"
SPARSE_MODEL = "prithivida/Splade_PP_en_v1"
def __init__(self, collection_name = None):
self.collection_name = collection_name
# initialize Qdrant client
self.qdrant_client = QdrantClient(<url>)
self.qdrant_client.set_model(self.DENSE_MODEL)
# comment this line to use dense vectors only
self.qdrant_client.set_sparse_model(self.SPARSE_MODEL)
def store(self, documents, metadatas):
self.qdrant_client.add(
collection_name = self.collection_name,
documents = documents,
metadata = metadatas
)
db = DB()
What Python version are you on? e.g. python --version
Python3.11 pip
FastEmbed version
On latest
What os are you seeing the problem on?
Linux
Relevant stack traces and/or logs
Invalid credentials in Authorization header Falling back to other sources.
2025-03-14 11:08:19.111 | ERROR | fastembed.common.model_management:download_model:450 - Could not download model from either source, sleeping for 9.0 seconds, 1 retries left.
2025-03-14 11:08:28.205 | ERROR | fastembed.common.model_management:download_model:429 - Could not download model from HuggingFace: 401 Client Error: Unauthorized for url: https://huggingface.co/api/models/Qdrant/SPLADE_PP_en_v1 (Request ID: Root=1-67d40e2c-7540f5184c06df970fa49cd8;e1d630bf-29d9-498f-aa7f-b43ab6f105ca)
@NirantK can you assist?
Hey @microcoder-py
@NirantK is no longer a maintainer of fastembed
We'll look into your problem asap
@joein noted. Most likely occuring because HF is now forcing access tokens, but this same code worked just fine a week ago. Should I downgrade my fastembed?
@microcoder-py This error does not seem to be dependant on fastembed version It seems like a problem with a token, afaik all the models are public and do not require a token (except, maybe, colpali or jina)
What is the request to the following response?
curl -I https://huggingface.co/api/models/Qdrant/Splade_PP_en_v1
Could you try downloading this model manually with huggingface_hub?
from huggingface_hub import snapshot_download
snapshot_download(repo_id="Qdrant/Splade_PP_en_v1")
Does it work?
If it does not, does it work if you explicitly turn off authorization?
from huggingface_hub import snapshot_download
snapshot_download(repo_id="Qdrant/Splade_PP_en_v1", use_auth_token=False)
Could the HF token you're using be outdated or deleted on HF?
@joein
HTTP/2 200
content-type: application/json; charset=utf-8
content-length: 1468
date: Fri, 14 Mar 2025 11:42:40 GMT
x-powered-by: huggingface-moon
cross-origin-opener-policy: same-origin
referrer-policy: strict-origin-when-cross-origin
x-request-id: Root=1-67d41630-3cfe6c3f217e5cae5c9aebe1
access-control-allow-origin: https://huggingface.co
vary: Origin
access-control-expose-headers: X-Repo-Commit,X-Request-Id,X-Error-Code,X-Error-Message,X-Total-Count,ETag,Link,Accept-Ranges,Content-Range,X-Xet-Access-Token,X-Xet-Token-Expiration,X-Xet-Refresh-Route,X-Xet-Cas-Url,X-Xet-Hash
etag: W/"5bc-i0SgjVqQUpIrxEVDIIuA+mjSac4"
x-cache: Miss from cloudfront
via: 1.1 0c62e8c958eb0d54f812cda141e660b6.cloudfront.net (CloudFront)
x-amz-cf-pop: LHR62-C4
x-amz-cf-id: RPUl1Kh7pdAAMvFVrpWAE9jFrwi3Fo2SwCKGkhx3gjE1cE1goksykw==
And I have not been using any token whatsoever
@microcoder-py
what about the code snippets with huggingface_hub?
@joein it works when auth is not enforced. It's a token issue. A small change to the fastembed codebase should do the trick
@joein
Line 122 in fastembed/common/model_managemen.py
return snapshot_download(
repo_id=hf_source_repo,
allow_patterns=allow_patterns,
cache_dir=cache_dir,
local_files_only=local_files_only,
use_auth_token = False,
**kwargs,
)
Added use_auth_token = False. That did the job
This only worked for 0.4.1, still fails with 0.6.0. I downgraded the version for my deployment
@microcoder-py I am afraid, that we can not do that, since some of the models require authentication (e.g., colpali since it is built upon google's gemma).
Also, it seems that the model's name in our code was a little bit different, (should be Qdrant/Splade_PP_en_v1 instead of Qdrant/SPLADE_PP_en_v1)
I'll create a PR to address this, I think it might fix the issue
#499