模型来源#

Xinference 支持从不同的来源下载各种模型。

Automatic Detection#

By default, Xinference automatically decides between Hugging Face and ModelScope when launching a model: it probes whether the Hugging Face endpoint is reachable (mirrors set via HF_ENDPOINT and proxies set via HTTP_PROXY / HTTPS_PROXY are honored). If it is reachable, models are downloaded from Hugging Face; otherwise Xinference falls back to ModelScope. An HTTP error response (for example 403/407 from a blocking corporate proxy, or a 5xx from a broken mirror) counts as unreachable, since downloads would fail anyway. When Hugging Face offline mode is enabled (HF_HUB_OFFLINE=1 or TRANSFORMERS_OFFLINE=1), no probe runs and Hugging Face is selected directly, so air-gapped deployments keep reading from their pre-populated local Hugging Face cache. The detection result is cached, so the probe runs at most once per process, and its timeout can be tuned via the XINFERENCE_HUB_DETECT_TIMEOUT environment variable (default: 3 seconds).

You can also request the detection explicitly by passing --download_hub auto when launching a model, or setting XINFERENCE_MODEL_SRC=auto.

To pin a download source instead of relying on detection, set XINFERENCE_MODEL_SRC to huggingface or modelscope, or pass --download_hub when launching a model.

HuggingFace#

Xinference downloads the required models from the official Hugging Face model repository when it is reachable.

备注

如果你的网络无法连接到 HuggingFace ,你可以通过环境变量指定 HuggingFace 镜像网站:HF_ENDPOINT=https://hf-mirror.com

ModelScope#

When the Hugging Face endpoint is not reachable (for example, no proxy is available), Xinference automatically falls back to downloading models from ModelScope.

You can also force this by manually setting an environment variable XINFERENCE_MODEL_SRC=modelscope.

请在模型的详情页面上查看它是否支持从 ModelScope 进行下载。如果一个模型支持从 ModelScope 下载,模型信息中的 Model Hubs 这一项会包含 ModelScope。