跳转到内容
GitHub

配置 Hugging Face

通过 HF_ENDPOINT 让 hf 与 Transformers 的模型下载经过 Depsilo /huggingface 路由。

之前https://huggingface.co
之后http://localhost:23333/huggingface

模型与数据集通过 HF_ENDPOINT 指向 Depsilo 的 /huggingface 路由。

终端窗口
export HF_ENDPOINT=http://localhost:23333/huggingface
hf download prajjwal1/bert-tiny --local-dir /tmp/bert-tiny

Python 中使用 transformers 等库时同样读取 HF_ENDPOINT,可在 shell、CI secret 或项目 .env 中设置。

  1. 下载一个小模型

    终端窗口
    hf download prajjwal1/bert-tiny --local-dir /tmp/bert-tiny
  2. 再次执行同一命令

    第二次请求应命中 Depsilo 缓存,而不是再次访问 huggingface.co。

  3. 在 Admin 中确认流量

    在 Access logs 中核对 /huggingface 请求与缓存结果。