Skip to content

Fix: Support HF_HOME and HF_ENDPOINT#187

Merged
sonam-pankaj95 merged 1 commit into
StarlightSearch:devfrom
DayNice:fix/env-huggingface
Nov 7, 2025
Merged

Fix: Support HF_HOME and HF_ENDPOINT#187
sonam-pankaj95 merged 1 commit into
StarlightSearch:devfrom
DayNice:fix/env-huggingface

Conversation

@DayNice

@DayNice DayNice commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

Change Api::new() into ApiBuilder::from_env().build(). This fixes cases not handled in PR #179.

You can see in the source code that Api::new() is simply a call to ApiBuilder::new().build(). To opt-in for supporting environment variables HF_HUB and HF_ENDPOINT, we must explicitly use ApiBuilder::from_env().build() for all API calls.

Affected files are as follows:

  • rust/src/
    • embeddings/local/
    • clip.rs: L206
    • colbert.rs: L55
    • colpali.rs: L46
    • colpali_ort.rs: L34
    • colsmol.rs: L24
    • ort_bert.rs: L65, L421
    • ort_colsmol.rs: L37
    • ort_jina.rs: L66
    • file_processor/audio/audio_processor.rs: L461
    • models/idefics3/
      • array_processing.rs: L68, L704
      • tensor_processing.rs: L506, L528
    • reranker/model.rs: L44

Tested that it works as follows.

export HF_HOME=/tmp/hf_home

hf cache scan
# Cache directory not found: /tmp/hf_home/hub

# trigger local caching
python -c 'from embed_anything import Reranker, Dtype; Reranker.from_pretrained("zhiqing/Qwen3-Reranker-0.6B-ONNX", dtype=Dtype.F32)'

hf cache scan
# REPO ID                          REPO TYPE SIZE ON DISK NB FILES LAST_ACCESSED     LAST_MODIFIED     REFS LOCAL PATH              
# -------------------------------- --------- ------------ -------- ----------------- ----------------- ---- ----------------------------------------------------------
# zhiqing/Qwen3-Reranker-0.6B-ONNX model             1.2G        4 a few seconds ago a few seconds ago main /tmp/hf_home/hub/models--zhiqing--Qwen3-Reranker-0.6B-ONNX
# 
# Done in 0.0s. Scanned 1 repo(s) for a total of 1.2G.

@sonam-pankaj95

Copy link
Copy Markdown
Collaborator

Thank you @DayNice for your contributions!! I will soon review the others.

@sonam-pankaj95 sonam-pankaj95 merged commit ebcff7a into StarlightSearch:dev Nov 7, 2025
5 checks passed
@DayNice DayNice deleted the fix/env-huggingface branch November 7, 2025 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants