From 6f5f28f253b0af8557ad2b3cd6fa14dd4e3ab902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?apolin=C3=A1rio?= Date: Thu, 7 Dec 2023 15:33:43 +0000 Subject: [PATCH] Add `preload_from_hub` to the docs (#1156) * Add `preload_from_hub` to the docs * Update docs/hub/spaces-config-reference.md Co-authored-by: Pedro Cuenca * Update docs/hub/spaces-config-reference.md Co-authored-by: Pedro Cuenca * Add disclaimer about where file is saved * Update docs/hub/spaces-config-reference.md Co-authored-by: Julien Chaumond --------- Co-authored-by: Pedro Cuenca Co-authored-by: Julien Chaumond --- docs/hub/spaces-config-reference.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/hub/spaces-config-reference.md b/docs/hub/spaces-config-reference.md index 78b735bd1..47c5c0f32 100644 --- a/docs/hub/spaces-config-reference.md +++ b/docs/hub/spaces-config-reference.md @@ -97,3 +97,21 @@ custom_headers: ``` *Note:* all headers and values must be lowercase. + +**`preload_from_hub`**: _List[string]_ +Specify a list of Hugging Face Hub models or other large files to be preloaded during the build time of your Space. This optimizes the startup time by having the files ready when your application starts. This is particularly useful for Spaces that rely on large models or datasets that would otherwise need to be downloaded at runtime. + +The format for each item is `"repository_name"` to download all files from a repository, or `"repository_name file1,file2"` for downloading specific files within that repository. You can also specify a specific commit to download using the format `"repository_name file1,file2 commit_sha256"`. + +Example usage: +```yaml +preload_from_hub: + - warp-ai/wuerstchen-prior text_encoder/model.safetensors,prior/diffusion_pytorch_model.safetensors + - coqui/XTTS-v1 + - gpt2 config.json 11c5a3d5811f50298f278a704980280950aedb10 +``` +In this example, the Space will preload specific .safetensors files from `warp-ai/wuerstchen-prior`, the complete `coqui/XTTS-v1` repository, and a specific revision of the `config.json` file in the `gpt2` repository from the Hugging Face Hub during build time. + + + Files are saved in the default `huggingface_hub` disk cache `~/.cache/huggingface/hub`. If you application expects them elsewhere or you changed your `HF_HOME` variable, this pre-loading does not follow that at this time. +