Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"Verwalten des huggingface_hub Cache-Systems","local":"verwalten-des-huggingfacehub-cache-systems","sections":[{"title":"Caching verstehen","local":"caching-verstehen","sections":[{"title":"Refs","local":"refs","sections":[],"depth":3},{"title":"Blobs","local":"blobs","sections":[],"depth":3},{"title":"Snapshots","local":"snapshots","sections":[],"depth":3},{"title":".no_exist (fortgeschritten)","local":"noexist-fortgeschritten","sections":[],"depth":3},{"title":"In der Praxis","local":"in-der-praxis","sections":[],"depth":3},{"title":"Einschränkungen","local":"einschränkungen","sections":[],"depth":3}],"depth":2},{"title":"Assets zwischenspeichern","local":"assets-zwischenspeichern","sections":[{"title":"Assets in der Praxis","local":"assets-in-der-praxis","sections":[],"depth":3}],"depth":2},{"title":"Cache scannen","local":"cache-scannen","sections":[{"title":"Cache im Terminal prüfen","local":"cache-im-terminal-prüfen","sections":[{"title":"Mit Shell-Tools filtern","local":"mit-shell-tools-filtern","sections":[],"depth":4}],"depth":3},{"title":"Den Cache von Python aus scannen","local":"den-cache-von-python-aus-scannen","sections":[],"depth":3}],"depth":2},{"title":"Cache leeren","local":"cache-leeren","sections":[{"title":"Löschstrategie","local":"löschstrategie","sections":[],"depth":3},{"title":"Cache vom Terminal aus leeren","local":"cache-vom-terminal-aus-leeren","sections":[],"depth":3},{"title":"Cache aus Python leeren","local":"cache-aus-python-leeren","sections":[],"depth":3}],"depth":2}],"depth":1}"> | |
| <link href="/docs/huggingface_hub/pr_4113/de/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/de/_app/immutable/entry/start.78846203.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/de/_app/immutable/chunks/scheduler.de5597d1.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/de/_app/immutable/chunks/singletons.c332abcc.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/de/_app/immutable/chunks/paths.162adda8.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/de/_app/immutable/entry/app.f549f98a.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/de/_app/immutable/chunks/preload-helper.cc57ebc4.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/de/_app/immutable/chunks/index.bf1177c2.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/de/_app/immutable/nodes/0.9ce3ec2a.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/de/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/de/_app/immutable/nodes/7.8cb047ea.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/de/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.c5d5679c.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/de/_app/immutable/chunks/CodeBlock.4f67b398.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"Verwalten des huggingface_hub Cache-Systems","local":"verwalten-des-huggingfacehub-cache-systems","sections":[{"title":"Caching verstehen","local":"caching-verstehen","sections":[{"title":"Refs","local":"refs","sections":[],"depth":3},{"title":"Blobs","local":"blobs","sections":[],"depth":3},{"title":"Snapshots","local":"snapshots","sections":[],"depth":3},{"title":".no_exist (fortgeschritten)","local":"noexist-fortgeschritten","sections":[],"depth":3},{"title":"In der Praxis","local":"in-der-praxis","sections":[],"depth":3},{"title":"Einschränkungen","local":"einschränkungen","sections":[],"depth":3}],"depth":2},{"title":"Assets zwischenspeichern","local":"assets-zwischenspeichern","sections":[{"title":"Assets in der Praxis","local":"assets-in-der-praxis","sections":[],"depth":3}],"depth":2},{"title":"Cache scannen","local":"cache-scannen","sections":[{"title":"Cache im Terminal prüfen","local":"cache-im-terminal-prüfen","sections":[{"title":"Mit Shell-Tools filtern","local":"mit-shell-tools-filtern","sections":[],"depth":4}],"depth":3},{"title":"Den Cache von Python aus scannen","local":"den-cache-von-python-aus-scannen","sections":[],"depth":3}],"depth":2},{"title":"Cache leeren","local":"cache-leeren","sections":[{"title":"Löschstrategie","local":"löschstrategie","sections":[],"depth":3},{"title":"Cache vom Terminal aus leeren","local":"cache-vom-terminal-aus-leeren","sections":[],"depth":3},{"title":"Cache aus Python leeren","local":"cache-aus-python-leeren","sections":[],"depth":3}],"depth":2}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="verwalten-des-huggingfacehub-cache-systems" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#verwalten-des-huggingfacehub-cache-systems"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Verwalten des huggingface_hub Cache-Systems</span></h1> <h2 class="relative group"><a id="caching-verstehen" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#caching-verstehen"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Caching verstehen</span></h2> <p data-svelte-h="svelte-61rybt">Das Hugging Face Hub Cache-System wurde entwickelt, um der zentrale Cache zu sein, | |
| der zwischen Bibliotheken geteilt wird, welche vom Hub abhängen. Es wurde in v0.8.0 aktualisiert, | |
| um das erneute Herunterladen von Dateien zwischen Revisionen zu verhindern.</p> <p data-svelte-h="svelte-pr21fp">Das Cache-System ist wie folgt aufgebaut:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-tag"><<span class="hljs-name">CACHE_DIR</span>></span> | |
| ├─ <span class="hljs-tag"><<span class="hljs-name">MODELS</span>></span> | |
| ├─ <span class="hljs-tag"><<span class="hljs-name">DATASETS</span>></span> | |
| ├─ <span class="hljs-tag"><<span class="hljs-name">SPACES</span>></span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-kafc54">Der <code><CACHE_DIR></code> ist normalerweise das Home-Verzeichnis Ihres Benutzers. Es kann jedoch mit dem | |
| <code>cache_dir</code>-Argument in allen Methoden oder durch Angabe der Umgebungsvariablen | |
| <code>HF_HOME</code> oder <code>HF_HUB_CACHE</code> angepasst werden.</p> <p data-svelte-h="svelte-2zg9up">Modelle, Datensätze und Räume teilen eine gemeinsame Wurzel. | |
| Jedes dieser Repositories enthält den Repository-Typ, den Namensraum (Organisation oder Benutzername), | |
| falls vorhanden, und den Repository-Namen:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><<span class="hljs-comment">CACHE_DIR</span>> | |
| <span class="hljs-comment">├─ models</span><span class="hljs-literal">--</span><span class="hljs-comment">julien</span><span class="hljs-literal">-</span><span class="hljs-comment">c</span><span class="hljs-literal">--</span><span class="hljs-comment">EsperBERTo</span><span class="hljs-literal">-</span><span class="hljs-comment">small</span> | |
| <span class="hljs-comment">├─ models</span><span class="hljs-literal">--</span><span class="hljs-comment">lysandrejik</span><span class="hljs-literal">--</span><span class="hljs-comment">arxiv</span><span class="hljs-literal">-</span><span class="hljs-comment">nlp</span> | |
| <span class="hljs-comment">├─ models</span><span class="hljs-literal">--</span><span class="hljs-comment">bert</span><span class="hljs-literal">-</span><span class="hljs-comment">base</span><span class="hljs-literal">-</span><span class="hljs-comment">cased</span> | |
| <span class="hljs-comment">├─ datasets</span><span class="hljs-literal">--</span><span class="hljs-comment">glue</span> | |
| <span class="hljs-comment">├─ datasets</span><span class="hljs-literal">--</span><span class="hljs-comment">huggingface</span><span class="hljs-literal">--</span><span class="hljs-comment">DataMeasurementsFiles</span> | |
| <span class="hljs-comment">├─ spaces</span><span class="hljs-literal">--</span><span class="hljs-comment">dalle</span><span class="hljs-literal">-</span><span class="hljs-comment">mini</span><span class="hljs-literal">--</span><span class="hljs-comment">dalle</span><span class="hljs-literal">-</span><span class="hljs-comment">mini</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-br50js">Innerhalb dieser Ordner werden nun alle Dateien vom Hub heruntergeladen. Das Caching stellt sicher, | |
| dass eine Datei nicht zweimal heruntergeladen wird, wenn sie bereits existiert und nicht aktualisiert wurde; | |
| wurde sie jedoch aktualisiert und Sie fordern die neueste Datei an, wird die neueste Datei heruntergeladen | |
| (während die vorherige Datei intakt bleibt, falls Sie sie erneut benötigen).</p> <p data-svelte-h="svelte-9n877q">Um dies zu erreichen, enthalten alle Ordner dasselbe Grundgerüst:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><CACHE_DIR> | |
| ├─ datasets<span class="hljs-params">--glue</span> | |
| │ ├─ refs | |
| │ ├─ blobs | |
| │ ├─ snapshots | |
| <span class="hljs-string">...</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1dmpcjk">Jeder Ordner ist so gestaltet, dass er das Folgende enthält:</p> <h3 class="relative group"><a id="refs" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#refs"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Refs</span></h3> <p data-svelte-h="svelte-14k8h2t">Der Ordner <code>refs</code> enthält Dateien, die die neueste Revision des gegebenen Verweises anzeigen. | |
| Zum Beispiel, wenn wir zuvor eine Datei aus dem <code>main</code>-Branch eines Repositories abgerufen haben, | |
| wird der Ordner <code>refs</code> eine Datei namens <code>main</code> enthalten, die selbst den Commit-Identifikator der aktuellen HEAD-Branch enthält.</p> <p data-svelte-h="svelte-1n0msig">Wenn der neueste Commit von <code>main</code> den Identifikator <code>aaaaaa</code> hat, dann enthält er <code>aaaaaa</code>.</p> <p data-svelte-h="svelte-1f9smln">Wenn derselbe Zweig mit einem neuen Commit aktualisiert wird, der den Identifikator <code>bbbbbb</code> hat, | |
| wird das erneute Herunterladen einer Datei von diesem Verweis die Datei <code>refs/main</code> aktualisieren, um <code>bbbbbb</code> zu enthalten.</p> <h3 class="relative group"><a id="blobs" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#blobs"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Blobs</span></h3> <p data-svelte-h="svelte-1eldkes">Der Ordner <code>blobs</code> enthält die tatsächlichen Dateien, die wir heruntergeladen haben. Der Name jeder Datei ist ihr Hash.</p> <h3 class="relative group"><a id="snapshots" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#snapshots"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Snapshots</span></h3> <p data-svelte-h="svelte-o3uzfk">Der Ordner <code>snapshots</code> enthält Symlinks zu den oben erwähnten Blobs. | |
| Er besteht selbst aus mehreren Ordnern: einem pro bekannter Revision!</p> <p data-svelte-h="svelte-1mgfwmw">In der obigen Erklärung hatten wir zunächst eine Datei von der Revision <code>aaaaaa</code> abgerufen, bevor wir eine Datei | |
| von der Revision <code>bbbbbb</code> abgerufen haben. In dieser Situation hätten wir jetzt zwei Ordner im Ordner <code>snapshots</code>: <code>aaaaaa</code> und <code>bbbbbb</code>.</p> <p data-svelte-h="svelte-1vu57r6">In jedem dieser Ordner leben Symlinks, die die Namen der Dateien haben, die wir heruntergeladen haben. | |
| Wenn wir zum Beispiel die Datei <code>README.md</code> in der Revision <code>aaaaaa</code> heruntergeladen hätten, hätten wir den folgenden Pfad:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><CACHE_DIR><span class="hljs-regexp">/<REPO_NAME>/</span>snapshots<span class="hljs-regexp">/aaaaaa/</span>README.md<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-gqcyer">Diese <code>README.md</code>-Datei ist tatsächlich ein Symlink, der auf den Blob verweist, der den Hash der Datei hat.</p> <p data-svelte-h="svelte-1yxwzcf">Durch das Erstellen des Grundgerüsts auf diese Weise ermöglichen wir den Mechanismus der Dateifreigabe: | |
| Wenn dieselbe Datei in der Revision <code>bbbbbb</code> abgerufen wurde, hätte sie denselben Hash und die Datei müsste nicht erneut heruntergeladen werden.</p> <h3 class="relative group"><a id="noexist-fortgeschritten" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#noexist-fortgeschritten"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>.no_exist (fortgeschritten)</span></h3> <p data-svelte-h="svelte-2u9061">Zusätzlich zu den Ordnern <code>blobs</code>, <code>refs</code> und <code>snapshots</code> könnten Sie in Ihrem Cache auch einen <code>.no_exist</code> Ordner finden. | |
| Dieser Ordner hält fest, welche Dateien Sie einmal versucht haben herunterzuladen, die jedoch nicht auf dem Hub vorhanden sind. | |
| Seine Struktur ist dieselbe wie der <code>snapshots</code> Ordner mit einem Unterordner pro bekannter Revision:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><CACHE_DIR><span class="hljs-regexp">/<REPO_NAME>/</span>.no_exist<span class="hljs-regexp">/aaaaaa/</span>config_that_does_not_exist.json<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1j1bmx5">Im Gegensatz zum <code>snapshots</code> Ordner handelt es sich bei den Dateien um einfache leere Dateien (keine Symlinks). | |
| In diesem Beispiel existiert die Datei <code>"config_that_does_not_exist.json"</code> nicht auf dem Hub für die Revision <code>"aaaaaa"</code>. | |
| Da dieser Ordner nur leere Dateien speichert, ist sein Speicherplatzverbrauch vernachlässigbar.</p> <p data-svelte-h="svelte-1a83sun">Sie fragen sich jetzt vielleicht, warum diese Information überhaupt relevant ist? | |
| In einigen Fällen versucht ein Framework, optionale Dateien für ein Modell zu laden. | |
| Das Speichern der Nicht-Existenz optionaler Dateien beschleunigt das Laden eines Modells, da 1 HTTP-Anfrage pro möglicher optionaler Datei gespart wird. | |
| Dies ist zum Beispiel bei <code>transformers</code> der Fall, wo jeder Tokenizer zusätzliche Dateien unterstützen kann. Beim ersten Laden des Tokenizers | |
| auf Ihrem Gerät wird im Cache gespeichert, welche optionalen Dateien vorhanden sind (und welche nicht), um die Ladezeit bei den nächsten Initialisierungen zu beschleunigen.</p> <p data-svelte-h="svelte-e89t87">Um zu testen, ob eine Datei lokal im Cache gespeichert ist (ohne eine HTTP-Anfrage zu senden), können Sie die <code>try_to_load_from_cache()</code> Hilfsfunktion verwenden. | |
| Sie gibt entweder den Dateipfad zurück (falls vorhanden und im Cache gespeichert), das Objekt <code>_CACHED_NO_EXIST</code> (wenn die Nicht-Existenz im Cache gespeichert ist) | |
| oder <code>None</code> (wenn wir es nicht wissen).</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> try_to_load_from_cache, _CACHED_NO_EXIST | |
| filepath = try_to_load_from_cache() | |
| <span class="hljs-keyword">if</span> <span class="hljs-built_in">isinstance</span>(filepath, <span class="hljs-built_in">str</span>): | |
| <span class="hljs-comment"># file exists and is cached</span> | |
| ... | |
| <span class="hljs-keyword">elif</span> filepath <span class="hljs-keyword">is</span> _CACHED_NO_EXIST: | |
| <span class="hljs-comment"># non-existence of file is cached</span> | |
| ... | |
| <span class="hljs-keyword">else</span>: | |
| <span class="hljs-comment"># file is not cached</span> | |
| ...<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="in-der-praxis" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#in-der-praxis"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>In der Praxis</span></h3> <p data-svelte-h="svelte-1no2ew1">In der Praxis sollte Ihr Cache folgendermaßen aussehen:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --> [ 96] . | |
| └── [ 160] models--julien-c--EsperBERTo-small | |
| ├── [ 160] blobs | |
| │ ├── [321M] 403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd | |
| │ ├── [ 398] 7cb18dc9bafbfcf74629a4b760af1b160957a83e | |
| │ └── [1.4K] d7edf6bd2a681fb0175f7735299831ee1b22b812 | |
| ├── [ 96] refs | |
| │ └── [ 40] main | |
| └── [ 128] snapshots | |
| ├── [ 128] 2439f60ef33a0d46d85da5001d52aeda5b00ce9f | |
| │ ├── [ 52] README.md -> ../../blobs/d7edf6bd2a681fb0175f7735299831ee1b22b812 | |
| │ └── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd | |
| └── [ 128] bbc77c8132af1cc5cf678da3f1ddf2de43606d48 | |
| ├── [ 52] README.md -> ../../blobs/7cb18dc9bafbfcf74629a4b760af1b160957a83e | |
| └── [ 76] pytorch_model.bin -> ../../blobs/403450e234d65943a7dcf7e05a771ce3c92faa84dd07db4ac20f592037a1e4bd<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="einschränkungen" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#einschränkungen"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Einschränkungen</span></h3> <p data-svelte-h="svelte-ua6zs5">Um ein effizientes Cache-System zu haben, verwendet <code>huggingface-hub</code> Symlinks. Allerdings | |
| werden Symlinks nicht auf allen Maschinen unterstützt. Dies ist eine bekannte Einschränkung, | |
| insbesondere bei Windows. Wenn dies der Fall ist, verwendet <code>huggingface_hub</code> nicht das <code>blobs/</code> Verzeichnis, | |
| sondern speichert die Dateien direkt im <code>snapshots/</code> Verzeichnis. Dieser Workaround ermöglicht es den Nutzern, | |
| Dateien vom Hub auf genau die gleiche Weise herunterzuladen und zu cachen. | |
| Auch Werkzeuge zur Überprüfung und Löschung des Caches (siehe unten) werden unterstützt. | |
| Allerdings ist das Cache-System weniger effizient, da eine einzelne Datei möglicherweise mehrmals heruntergeladen wird, | |
| wenn mehrere Revisionen des gleichen Repos heruntergeladen werden.</p> <p data-svelte-h="svelte-ld2pcs">Wenn Sie von dem Symlink-basierten Cache-System auf einem Windows-Gerät profitieren möchten, | |
| müssen Sie entweder den <a href="https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development" rel="nofollow">Entwicklermodus aktivieren</a> | |
| oder Python als Administrator ausführen.</p> <p data-svelte-h="svelte-pd3h3o">Wenn Symlinks nicht unterstützt werden, wird dem Nutzer eine Warnmeldung angezeigt, um ihn darauf hinzuweisen, | |
| dass er eine eingeschränkte Version des Cache-Systems verwendet. Diese Warnung kann durch Setzen der | |
| Umgebungsvariable <code>HF_HUB_DISABLE_SYMLINKS_WARNING</code> auf true deaktiviert werden.</p> <h2 class="relative group"><a id="assets-zwischenspeichern" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#assets-zwischenspeichern"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Assets zwischenspeichern</span></h2> <p data-svelte-h="svelte-1jhuhng">Zusätzlich zum Zwischenspeichern von Dateien aus dem Hub benötigen nachgelagerte Bibliotheken | |
| oft das Zwischenspeichern von anderen Dateien, die in Verbindung mit HF stehen, aber nicht | |
| direkt von <code>huggingface_hub</code> behandelt werden (zum Beispiel: Dateien, die von GitHub heruntergeladen werden, | |
| vorverarbeitete Daten, Protokolle,…). Um diese Dateien, die als <code>assets</code> bezeichnet werden, zwischenzuspeichern, | |
| kann man <code>cached_assets_path()</code> verwenden. Dieser kleine Helfer generiert Pfade im HF-Cache auf eine einheitliche Weise, | |
| basierend auf dem Namen der anfragenden Bibliothek und optional auf einem Namensraum und einem Unterordnernamen. | |
| Das Ziel ist, dass jede nachgelagerte Bibliothek ihre Assets auf ihre eigene Weise verwaltet | |
| (z.B. keine Regelung über die Struktur), solange sie im richtigen Assets-Ordner bleibt. | |
| Diese Bibliotheken können dann die Werkzeuge von <code>huggingface_hub</code> nutzen, um den Cache zu verwalten, | |
| insbesondere um Teile der Assets über einen CLI-Befehl zu scannen und zu löschen.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> cached_assets_path | |
| assets_path = cached_assets_path(library_name=<span class="hljs-string">"datasets"</span>, namespace=<span class="hljs-string">"SQuAD"</span>, subfolder=<span class="hljs-string">"download"</span>) | |
| something_path = assets_path / <span class="hljs-string">"something.json"</span> <span class="hljs-comment"># Machen Sie, was Sie möchten, in Ihrem Assets-Ordner!</span><!-- HTML_TAG_END --></pre></div> <blockquote class="tip" data-svelte-h="svelte-jvz4yn"><p><code>cached_assets_path()</code> ist der empfohlene Weg, um Assets zu speichern, ist jedoch nicht verpflichtend. | |
| Wenn Ihre Bibliothek bereits ihren eigenen Cache verwendet, können Sie diesen gerne nutzen!</p></blockquote> <h3 class="relative group"><a id="assets-in-der-praxis" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#assets-in-der-praxis"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Assets in der Praxis</span></h3> <p data-svelte-h="svelte-1h2jt3o">In der Praxis sollte Ihr Assets-Cache wie der folgende Verzeichnisbaum aussehen:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --> assets/ | |
| └── datasets/ | |
| │ ├── SQuAD/ | |
| │ │ ├── downloaded/ | |
| │ │ ├── extracted/ | |
| │ │ └── processed/ | |
| │ ├── Helsinki-NLP--tatoeba_mt/ | |
| │ ├── downloaded/ | |
| │ ├── extracted/ | |
| │ └── processed/ | |
| └── transformers/ | |
| ├── default/ | |
| │ ├── something/ | |
| ├── bert-base-cased/ | |
| │ ├── default/ | |
| │ └── training/ | |
| hub/ | |
| └── models--julien-c--EsperBERTo-small/ | |
| ├── blobs/ | |
| │ ├── (...) | |
| │ ├── (...) | |
| ├── refs/ | |
| │ └── (...) | |
| └── [ 128] snapshots/ | |
| ├── 2439f60ef33a0d46d85da5001d52aeda5b00ce9f/ | |
| │ ├── (...) | |
| └── bbc77c8132af1cc5cf678da3f1ddf2de43606d48/ | |
| └── (...)<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="cache-scannen" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#cache-scannen"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Cache scannen</span></h2> <p data-svelte-h="svelte-pixup6">Derzeit werden zwischengespeicherte Dateien nie aus Ihrem lokalen Verzeichnis gelöscht: | |
| Wenn Sie eine neue Revision eines Zweiges herunterladen, werden vorherige Dateien aufbewahrt, | |
| falls Sie sie wieder benötigen. Daher kann es nützlich sein, Ihr Cache-Verzeichnis zu scannen, | |
| um zu erfahren, welche Repos und Revisionen den meisten Speicherplatz beanspruchen. | |
| <code>huggingface_hub</code> bietet einen Helfer dafür, der über <code>hf</code> oder in einem Python-Skript verwendet werden kann.</p> <h3 class="relative group"><a id="cache-im-terminal-prüfen" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#cache-im-terminal-prüfen"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Cache im Terminal prüfen</span></h3> <p data-svelte-h="svelte-53xd1z">Die bequemste Möglichkeit, Ihren HF-Cache zu untersuchen, ist der Befehl <code>hf cache ls</code>. | |
| Er listet standardmäßig alle gecachten Repositories zusammen mit Größe, letzter Nutzung und Referenzen auf.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->➜ hf cache ls | |
| ID SIZE LAST_ACCESSED LAST_MODIFIED REFS | |
| ------------------------------------ ------- ------------- ------------- ------------------- | |
| dataset/glue 116.3K 4 days ago 4 days ago 2.4.0 main 1.17.0 | |
| dataset/google/fleurs 64.9M 1 week ago 1 week ago main refs/pr/1 | |
| model/Jean-Baptiste/camembert-ner 441.0M 2 weeks ago 16 hours ago main | |
| model/bert-base-cased 1.9G 1 week ago 2 years ago | |
| model/t5-base 10.1K 3 months ago 3 months ago main | |
| model/t5-small 970.7M 3 days ago 3 days ago main refs/pr/1 | |
| Found 6 repo(s) for a total of 12 revision(s) and 3.4G on disk.<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-jrfzsj">Mit <code>--revisions</code> wechseln Sie zur Ansicht auf Snapshot-Ebene. Filter akzeptieren | |
| menschenlesbare Werte, sodass Ausdrücke wie <code>size>1GB</code> oder <code>accessed>30d</code> sofort funktionieren:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->➜ hf cache ls --revisions --filter "size>1GB" --filter "accessed>30d" | |
| ID REVISION SIZE LAST_MODIFIED REFS | |
| ------------------------------------ ------------------ ------- ------------- ------------------- | |
| model/bert-base-cased 6d1d7a1a2a6cf4c2 1.9G 2 years ago | |
| model/t5-small 1c610f6b3f5e7d8a 1.1G 3 months ago main | |
| Found 2 repo(s) for a total of 2 revision(s) and 3.0G on disk.<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1xpwj2d">Brauchen Sie maschinenlesbare Ausgaben? <code>--format json</code> liefert strukturierte Objekte, | |
| <code>--format csv</code> erzeugt durch Komma getrennte Zeilen und <code>--quiet</code> gibt nur Kennungen aus. | |
| Alle Varianten lassen sich mit <code>--cache-dir</code> kombinieren, wenn Ihr Cache nicht unter <code>HF_HOME</code> | |
| liegt.</p> <h4 class="relative group"><a id="mit-shell-tools-filtern" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#mit-shell-tools-filtern"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Mit Shell-Tools filtern</span></h4> <p data-svelte-h="svelte-1m36dwq">Die Tabellen-Ausgabe lässt sich weiterhin mit bekannten Tools verarbeiten. Das folgende | |
| Beispiel zeigt alle Revisionen für <code>t5-small</code>:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->➜ eval "hf cache ls --revisions" | grep "t5-small" | |
| model/t5-small 1c610f6b3f5e7d8a 1.1G 3 months ago main | |
| model/t5-small 8f3ad1c90fed7a62 820.1M 2 weeks ago refs/pr/1<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="den-cache-von-python-aus-scannen" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#den-cache-von-python-aus-scannen"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Den Cache von Python aus scannen</span></h3> <p data-svelte-h="svelte-olmzw">Für eine erweiterte Nutzung verwenden Sie <code>scan_cache_dir()</code>, welches das von dem CLI-Tool | |
| aufgerufene Python-Dienstprogramm ist.</p> <p data-svelte-h="svelte-norace">Sie können es verwenden, um einen detaillierten Bericht zu erhalten, der um 4 Datenklassen herum strukturiert ist:</p> <ul data-svelte-h="svelte-1b698eq"><li><code>HFCacheInfo</code>: vollständiger Bericht, der von <code>scan_cache_dir()</code> zurückgegeben wird</li> <li><code>CachedRepoInfo</code>: Informationen über ein gecachtes Repo</li> <li><code>CachedRevisionInfo</code>: Informationen über eine gecachtes Revision (z.B. “snapshot) in einem Repo</li> <li><code>CachedFileInfo</code>: Informationen über eine gecachte Datei in einem Snapshot</li></ul> <p data-svelte-h="svelte-m9a3yy">Hier ist ein einfaches Anwendungs-Beispiel in Python. Siehe Referenz für Details.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> scan_cache_dir | |
| <span class="hljs-meta">>>> </span>hf_cache_info = scan_cache_dir() | |
| HFCacheInfo( | |
| size_on_disk=<span class="hljs-number">3398085269</span>, | |
| repos=<span class="hljs-built_in">frozenset</span>({ | |
| CachedRepoInfo( | |
| repo_id=<span class="hljs-string">'t5-small'</span>, | |
| repo_type=<span class="hljs-string">'model'</span>, | |
| repo_path=PosixPath(...), | |
| size_on_disk=<span class="hljs-number">970726914</span>, | |
| nb_files=<span class="hljs-number">11</span>, | |
| last_accessed=<span class="hljs-number">1662971707.3567169</span>, | |
| last_modified=<span class="hljs-number">1662971107.3567169</span>, | |
| revisions=<span class="hljs-built_in">frozenset</span>({ | |
| CachedRevisionInfo( | |
| commit_hash=<span class="hljs-string">'d78aea13fa7ecd06c29e3e46195d6341255065d5'</span>, | |
| size_on_disk=<span class="hljs-number">970726339</span>, | |
| snapshot_path=PosixPath(...), | |
| <span class="hljs-comment"># No `last_accessed` as blobs are shared among revisions</span> | |
| last_modified=<span class="hljs-number">1662971107.3567169</span>, | |
| files=<span class="hljs-built_in">frozenset</span>({ | |
| CachedFileInfo( | |
| file_name=<span class="hljs-string">'config.json'</span>, | |
| size_on_disk=<span class="hljs-number">1197</span> | |
| file_path=PosixPath(...), | |
| blob_path=PosixPath(...), | |
| blob_last_accessed=<span class="hljs-number">1662971707.3567169</span>, | |
| blob_last_modified=<span class="hljs-number">1662971107.3567169</span>, | |
| ), | |
| CachedFileInfo(...), | |
| ... | |
| }), | |
| ), | |
| CachedRevisionInfo(...), | |
| ... | |
| }), | |
| ), | |
| CachedRepoInfo(...), | |
| ... | |
| }), | |
| warnings=[ | |
| CorruptedCacheException(<span class="hljs-string">"Snapshots dir doesn't exist in cached repo: ..."</span>), | |
| CorruptedCacheException(...), | |
| ... | |
| ], | |
| )<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="cache-leeren" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#cache-leeren"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Cache leeren</span></h2> <p data-svelte-h="svelte-mxt064">Das Durchsuchen Ihres Caches ist interessant, aber was Sie normalerweise als Nächstes tun möchten, ist | |
| einige Teile zu löschen, um Speicherplatz freizugeben. Dies gelingt mit den CLI-Befehlen | |
| <code>hf cache rm</code> und <code>hf cache prune</code>. Alternativ können Sie programmatisch den | |
| <code>delete_revisions()</code>-Helfer des zurückgegebenen <code>HFCacheInfo</code>-Objekts nutzen.</p> <h3 class="relative group"><a id="löschstrategie" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#löschstrategie"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Löschstrategie</span></h3> <p data-svelte-h="svelte-1miwjrk">Um einige Cache zu löschen, müssen Sie eine Liste von Revisionen übergeben, die gelöscht werden sollen. Das Tool wird | |
| eine Strategie definieren, um den Speicherplatz auf der Grundlage dieser Liste freizugeben. Es gibt ein | |
| <code>DeleteCacheStrategy</code> Objekt zurück, das beschreibt, welche Dateien und Ordner gelöscht werden. Die | |
| <code>DeleteCacheStrategy</code> zeigt Ihnen, wie viel Speicherplatz voraussichtlich frei wird. | |
| Sobald Sie mit der Löschung einverstanden sind, müssen Sie sie ausführen, um die Löschung wirksam zu machen. | |
| Um Abweichungen zu vermeiden, können Sie ein Strategieobjekt nicht manuell bearbeiten.</p> <p data-svelte-h="svelte-15wrf8w">Die Strategie zur Löschung von Revisionen ist folgende:</p> <ul data-svelte-h="svelte-104cibx"><li>Der Ordner <code>snapshot</code>, der die Revisions-Symlinks enthält, wird gelöscht.</li> <li>Blob-Dateien, die nur von zu löschenden Revisionen verlinkt werden, werden ebenfalls gelöscht.</li> <li>Wenn eine Revision mit 1 oder mehreren <code>refs</code> verknüpft ist, werden die Referenzen gelöscht.</li> <li>Werden alle Revisionen aus einem Repo gelöscht, wird das gesamte zwischengespeicherte Repository gelöscht.</li></ul> <blockquote class="tip" data-svelte-h="svelte-1m3k9li"><p>Revisions-Hashes sind eindeutig über alle Repositories hinweg. <code>hf cache rm</code> akzeptiert daher sowohl | |
| Repository-Kennungen (z. B. <code>model/bert-base-uncased</code>) als auch einzelne Revisions-Hashes – bei einem Hash | |
| müssen Sie das Repository nicht zusätzlich angeben.</p></blockquote> <blockquote class="warning" data-svelte-h="svelte-hyufwr"><p>Wenn eine Revision im Cache nicht gefunden wird, wird sie stillschweigend ignoriert. Außerdem wird, wenn eine Datei | |
| oder ein Ordner beim Versuch, ihn zu löschen, nicht gefunden wird, eine Warnung protokolliert, aber es wird kein | |
| Fehler ausgelöst. Die Löschung wird für andere Pfade im | |
| <code>DeleteCacheStrategy</code> Objekt fortgesetzt.</p></blockquote> <h3 class="relative group"><a id="cache-vom-terminal-aus-leeren" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#cache-vom-terminal-aus-leeren"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Cache vom Terminal aus leeren</span></h3> <p data-svelte-h="svelte-1chcdyg">Verwenden Sie <code>hf cache rm</code>, um gecachte Repositories oder einzelne Revisionen zu löschen. | |
| Übergeben Sie dazu eine oder mehrere Repository-Kennungen (z. B. <code>model/bert-base-uncased</code>) oder Revisions-Hashes:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->➜ hf cache rm model/bert-base-cased | |
| About to delete 1 repo(s) totalling 1.9G. | |
| - model/bert-base-cased (entire repo) | |
| Proceed with deletion? [y/N]: y | |
| Deleted 1 repo(s) and 1 revision(s); freed 1.9G.<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1lhe2ci">Sie können Repositories und spezifische Revisionen mischen. Nutzen Sie <code>--dry-run</code>, um den Effekt vorab zu prüfen, | |
| oder <code>--yes</code>, wenn keine Rückfrage erscheinen soll:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->➜ hf cache rm model/t5-small 8f3ad1c --dry-run | |
| About to delete 1 repo(s) and 1 revision(s) totalling 1.1G. | |
| - model/t5-small: | |
| 8f3ad1c [main] 1.1G | |
| Dry run: no files were deleted.<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-g0dwrw">Wenn Ihr Cache nicht im Standardverzeichnis liegt, kombinieren Sie den Befehl mit <code>--cache-dir PFAD</code>.</p> <p data-svelte-h="svelte-1ch4bz2">Zum Aufräumen verwaister Snapshots steht <code>hf cache prune</code> bereit. Der Befehl entfernt automatisch alle | |
| Revisionen ohne Referenz:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->➜ hf cache prune | |
| About to delete 3 unreferenced revision(s) (2.4G total). | |
| - model/t5-small: | |
| 1c610f6b [refs/pr/1] 820.1M | |
| d4ec9b72 [(detached)] 640.5M | |
| - dataset/google/fleurs: | |
| 2b91c8dd [(detached)] 937.6M | |
| Proceed? [y/N]: y | |
| Deleted 3 unreferenced revision(s); freed 2.4G.<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1l1rpwx">Beide Befehle unterstützen <code>--dry-run</code>, <code>--yes</code> und <code>--cache-dir</code>, sodass Sie Vorschauen erzeugen, | |
| Automatisierungen bauen und alternative Cache-Verzeichnisse angeben können.</p> <h3 class="relative group"><a id="cache-aus-python-leeren" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#cache-aus-python-leeren"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Cache aus Python leeren</span></h3> <p data-svelte-h="svelte-1bifrgv">Für mehr Flexibilität können Sie auch die Methode <code>delete_revisions()</code> programmatisch verwenden. | |
| Hier ist ein einfaches Beispiel. Siehe Referenz für Details.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> scan_cache_dir | |
| <span class="hljs-meta">>>> </span>delete_strategy = scan_cache_dir().delete_revisions( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"81fd1d6e7847c99f5862c9fb81387956d99ec7aa"</span> | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"e2983b237dccf3ab4937c97fa717319a9ca1a96d"</span>, | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"6c0e6080953db56375760c0471a8c5f2929baf11"</span>, | |
| <span class="hljs-meta">... </span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-built_in">print</span>(<span class="hljs-string">"Will free "</span> + delete_strategy.expected_freed_size_str) | |
| Will free <span class="hljs-number">8.6</span>G | |
| <span class="hljs-meta">>>> </span>delete_strategy.execute() | |
| Cache deletion done. Saved <span class="hljs-number">8.6</span>G.<!-- HTML_TAG_END --></pre></div> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/huggingface_hub/blob/main/docs/source/de/guides/manage-cache.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_1iqh95q = { | |
| assets: "/docs/huggingface_hub/pr_4113/de", | |
| base: "/docs/huggingface_hub/pr_4113/de", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/huggingface_hub/pr_4113/de/_app/immutable/entry/start.78846203.js"), | |
| import("/docs/huggingface_hub/pr_4113/de/_app/immutable/entry/app.f549f98a.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 7], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 77 kB
- Xet hash:
- 03ab463902abbcfac0ca97abb372903db3bb735494b7150be688e6b3d5016aa2
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.