Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"huggingface_hub 캐시 시스템 관리하기","local":"manage-huggingfacehub-cache-system","sections":[{"title":"캐싱 이해하기","local":"understand-caching","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 (advanced)","local":"noexist-advanced","sections":[],"depth":3},{"title":"캐시 구조 예시","local":"in-practice","sections":[],"depth":3},{"title":"제한사항","local":"limitations","sections":[],"depth":3}],"depth":2},{"title":"캐싱 자산","local":"caching-assets","sections":[{"title":"자산 캐시 구조 예시","local":"assets-in-practice","sections":[],"depth":3}],"depth":2},{"title":"캐시 확인하기","local":"scan-your-cache","sections":[{"title":"터미널에서 캐시 확인하기","local":"scan-cache-from-the-terminal","sections":[{"title":"쉘 도구로 필터링하기","local":"grep-example","sections":[],"depth":4}],"depth":3},{"title":"파이썬에서 캐시 스캔하기","local":"scan-cache-from-python","sections":[],"depth":3}],"depth":2},{"title":"캐시 정리하기","local":"clean-your-cache","sections":[{"title":"전략적으로 삭제하기","local":"delete-strategy","sections":[],"depth":3},{"title":"터미널에서 캐시 정리하기","local":"clean-cache-from-the-terminal","sections":[],"depth":3},{"title":"파이썬에서 캐시 정리하기","local":"clean-cache-from-python","sections":[],"depth":3}],"depth":2}],"depth":1}"> | |
| <link href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/entry/start.e4d70577.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/chunks/scheduler.0cf4ef2e.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/chunks/singletons.7ad9a7dd.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/chunks/paths.5be5312b.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/entry/app.3b0f3b68.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/chunks/preload-helper.2e746cb0.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/chunks/index.abc433bf.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/nodes/0.c6150a55.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/nodes/10.057090fa.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.b2531632.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/ko/_app/immutable/chunks/CodeBlock.db16c7c8.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"huggingface_hub 캐시 시스템 관리하기","local":"manage-huggingfacehub-cache-system","sections":[{"title":"캐싱 이해하기","local":"understand-caching","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 (advanced)","local":"noexist-advanced","sections":[],"depth":3},{"title":"캐시 구조 예시","local":"in-practice","sections":[],"depth":3},{"title":"제한사항","local":"limitations","sections":[],"depth":3}],"depth":2},{"title":"캐싱 자산","local":"caching-assets","sections":[{"title":"자산 캐시 구조 예시","local":"assets-in-practice","sections":[],"depth":3}],"depth":2},{"title":"캐시 확인하기","local":"scan-your-cache","sections":[{"title":"터미널에서 캐시 확인하기","local":"scan-cache-from-the-terminal","sections":[{"title":"쉘 도구로 필터링하기","local":"grep-example","sections":[],"depth":4}],"depth":3},{"title":"파이썬에서 캐시 스캔하기","local":"scan-cache-from-python","sections":[],"depth":3}],"depth":2},{"title":"캐시 정리하기","local":"clean-your-cache","sections":[{"title":"전략적으로 삭제하기","local":"delete-strategy","sections":[],"depth":3},{"title":"터미널에서 캐시 정리하기","local":"clean-cache-from-the-terminal","sections":[],"depth":3},{"title":"파이썬에서 캐시 정리하기","local":"clean-cache-from-python","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="manage-huggingfacehub-cache-system" 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="#manage-huggingfacehub-cache-system"><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>huggingface_hub 캐시 시스템 관리하기</span></h1> <h2 class="relative group"><a id="understand-caching" 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="#understand-caching"><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>캐싱 이해하기</span></h2> <p data-svelte-h="svelte-lmeja8">Hugging Face Hub 캐시 시스템은 Hub에 의존하는 라이브러리 간에 공유되는 중앙 캐시로 설계되었습니다. v0.8.0에서 수정한 파일 간에 다시 다운로드하는 것을 방지하도록 업데이트되었습니다.</p> <p data-svelte-h="svelte-1443gak">캐시 시스템은 다음과 같이 설계되었습니다:</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-1qyw90c"><code><CACHE_DIR></code>는 보통 사용자의 홈 디렉토리입니다. 그러나 모든 메소드에서 <code>cache_dir</code> 인수를 사용하거나 <code>HF_HOME</code> 또는 <code>HF_HUB_CACHE</code> 환경 변수를 지정하여 사용자 정의할 수 있습니다.</p> <p data-svelte-h="svelte-1kadeos">모델, 데이터셋, 스페이스는 공통된 루트를 공유합니다. 각 리포지토리는 리포지토리 유형과 네임스페이스(조직 또는 사용자 이름이 있을 경우), 리포지토리 이름을 포함합니다:</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-1a2c6ad">Hub로부터 모든 파일이 이 폴더들 안에 다운로드됩니다. 캐싱은 파일이 이미 존재하고 업데이트되지 않은 경우, 파일을 두 번 다운로드하지 않도록 해줍니다. | |
| 하지만 파일이 업데이트되었고 최신 파일을 요청하면, 최신 파일을 다운로드합니다 (이전 파일은 그대로 유지되어 필요할 때 다시 사용할 수 있습니다).</p> <p data-svelte-h="svelte-bmk4e0">이를 위해 모든 폴더는 동일한 구조를 가집니다:</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-1j6pspu">각 폴더는 다음과 같은 내용을 포함하도록 구성되었습니다:</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-84iss"><code>refs</code> 폴더에는 주어진 참조의 최신 수정 버전을 나타내는 파일이 포함되어 있습니다. 예를 들어, 이전에 리포지토리의 <code>main</code> 브랜치에서 파일을 가져온 경우, <code>refs</code> 폴더에는 <code>main</code>이라는 이름의 파일이 포함되며, 이 파일 자체에는 현재 헤드의 커밋 식별자가 들어 있습니다.</p> <p data-svelte-h="svelte-391pik">만약 <code>main</code>의 최신 커밋 식별자가 <code>aaaaaa</code>라면, 그 파일에는 <code>aaaaaa</code>가 들어 있습니다.</p> <p data-svelte-h="svelte-xkjjee">같은 브랜치가 새로운 커밋으로 업데이트되어 <code>bbbbbb</code>라는 식별자를 갖게 되면, 해당 참조에서 파일을 다시 다운로드할 때 <code>refs/main</code> 파일은 <code>bbbbbb</code>로 업데이트됩니다.</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-c56e4v"><code>blobs</code> 폴더에는 실제로 다운로드된 파일이 포함되어 있습니다. 각 파일의 이름은 해당 파일의 해시값입니다.</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-8kilk8"><code>snapshots</code> 폴더에는 위에서 언급한 blobs에 대한 심볼릭 링크가 포함되어 있습니다. 이 폴더는 여러 개의 하위 폴더로 구성되어 있으며, 각 폴더는 알려진 수정 버전을 나타냅니다.</p> <p data-svelte-h="svelte-1xbz82b">위 설명에서, 처음에 <code>aaaaaa</code> 버전에서 파일을 가져왔고, 그 후에 <code>bbbbbb</code> 버전에서 파일을 가져왔습니다. 이 상황에서 <code>snapshots</code> 폴더에는 <code>aaaaaa</code>와 <code>bbbbbb</code>라는 두 개의 폴더가 있습니다.</p> <p data-svelte-h="svelte-wus6om">이 폴더들 각각에는 다운로드한 파일의 이름을 가진 심볼릭 링크가 있습니다. 예를 들어, <code>aaaaaa</code> 버전에서 <code>README.md</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 --><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-6c5i2d">그 <code>README.md</code> 파일은 실제로 해당 파일의 해시를 가진 blob에 대한 심볼릭 링크입니다.</p> <p data-svelte-h="svelte-v4esdi">이와 같은 구조를 생성함으로써 파일 공유 메커니즘이 열리게 됩니다. 동일한 파일을 <code>bbbbbb</code> 버전에서 가져온 경우, 동일한 해시를 가지게 되어 파일을 다시 다운로드할 필요가 없습니다.</p> <h3 class="relative group"><a id="noexist-advanced" 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-advanced"><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 (advanced)</span></h3> <p data-svelte-h="svelte-zanyjw"><code>blobs</code>, <code>refs</code>, <code>snapshots</code> 폴더 외에도 캐시에서 <code>.no_exist</code> 폴더를 찾을 수 있습니다. 이 폴더는 한 번 다운로드하려고 시도했지만 Hub에 존재하지 않는 파일을 기록합니다. 이 폴더의 구조는 <code>snapshots</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 --><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-14ubt1c"><code>snapshots</code> 폴더와 달리, 파일은 단순히 빈 파일입니다 (심볼릭 링크가 아님). 이 예에서 <code>"config_that_does_not_exist.json"</code> 파일은 <code>"aaaaaa"</code> 버전에 대해 Hub에 존재하지 않습니다. 빈 파일만 저장하므로, 이 폴더는 디스크 사용량을 크게 차지하지 않기에 무시할 수 있습니다.</p> <p data-svelte-h="svelte-16abje">그렇다면 이제 여러분은 왜 이 정보가 관련이 있는지 궁금해 할지도 모릅니다. 몇몇 경우에서는 프레임워크가 모델에 대한 옵션 파일들을 불러오려고 시도합니다. 존재하지 않는 옵션 파일들을 저장하면 가능한 옵션 파일당 1개의 HTTP 호출을 절약할 수 있어 모델을 더 빠르게 불러올 수 있습니다. 이는 예를 들어 각 토크나이저가 추가 파일을 지원하는 <code>transformers</code>에서 발생합니다. 처음으로 토크나이저를 로드할 때, 다음 초기화를 위해 로딩 시간을 더 빠르게 하기 위해 옵션 파일이 존재하는지 여부를 캐시합니다.</p> <p data-svelte-h="svelte-j6rt17">HTTP 요청을 만들지 않고 로컬로 캐시된 파일이 있는지 테스트하려면, <a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.try_to_load_from_cache">try_to_load_from_cache()</a> 헬퍼를 사용할 수 있습니다. 이것은 파일이 존재하고 캐시된 경우에는 파일 경로를, 존재하지 않음이 캐시된 경우에는 <code>_CACHED_NO_EXIST</code> 객체를, 알 수 없는 경우에는 <code>None</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 --><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"># 파일이 존재하고 캐시됩니다</span> | |
| ... | |
| <span class="hljs-keyword">elif</span> filepath <span class="hljs-keyword">is</span> _CACHED_NO_EXIST: | |
| <span class="hljs-comment"># 파일의 존재여부가 캐시됩니다</span> | |
| ... | |
| <span class="hljs-keyword">else</span>: | |
| <span class="hljs-comment"># 파일은 캐시되지 않습니다</span> | |
| ...<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="in-practice" 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-practice"><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>캐시 구조 예시</span></h3> <p data-svelte-h="svelte-di76nv">실제로는 캐시는 다음과 같은 트리 구조를 가질 것입니다:</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="limitations" 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="#limitations"><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>제한사항</span></h3> <p data-svelte-h="svelte-15zltu4">효율적인 캐시 시스템을 갖기 위해 <code>huggingface-hub</code>은 심볼릭 링크를 사용합니다. 그러나 모든 기기에서 심볼릭 링크를 지원하지는 않습니다. 특히 Windows에서 이러한 한계가 있다는 것이 알려져 있습니다. 이런 경우에는 <code>huggingface_hub</code>이 <code>blobs/</code> 디렉터리를 사용하지 않고 대신 파일을 직접 <code>snapshots/</code> 디렉터리에 저장합니다. 이 해결책을 통해 사용자는 Hub에서 파일을 다운로드하고 캐시하는 방식을 정확히 동일하게 사용할 수 있습니다. 캐시를 검사하고 삭제하는 도구들도 지원됩니다. 그러나 캐시 시스템은 동일한 리포지토리의 여러 수정 버전을 다운로드하는 경우 같은 파일이 여러 번 다운로드될 수 있기 때문에 효율적이지 않을 수 있습니다.</p> <p data-svelte-h="svelte-lp053g">Windows 기기에서 심볼릭 링크 기반 캐시 시스템의 이점을 누리려면, <a href="https://docs.microsoft.com/ko-kr/windows/apps/get-started/enable-your-device-for-development" rel="nofollow">개발자 모드를 활성화</a>하거나 Python을 관리자 권한으로 실행해야 합니다.</p> <p data-svelte-h="svelte-mz0rtf">심볼릭 링크가 지원되지 않는 경우, 사용자에게 캐시 시스템의 낮은 버전을 사용 중임을 알리는 경고 메시지가 표시됩니다. 이 경고는 <code>HF_HUB_DISABLE_SYMLINKS_WARNING</code> 환경 변수를 true로 설정하여 비활성화할 수 있습니다.</p> <h2 class="relative group"><a id="caching-assets" 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-assets"><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>캐싱 자산</span></h2> <p data-svelte-h="svelte-cb5lp8">Hub에서 파일을 캐시하는 것 외에도, 하위 라이브러리들은 종종 <code>huggingface_hub</code>에 직접 처리되지 않는 HF와 관련된 다른 파일을 캐시해야 할 때가 있습니다 (예: GitHub에서 다운로드한 파일, 전처리된 데이터, 로그 등). 이러한 파일, 즉 ‘자산(assets)‘을 캐시하기 위해 <a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.cached_assets_path">cached_assets_path()</a>를 사용할 수 있습니다. 이 헬퍼는 요청한 라이브러리의 이름과 선택적으로 네임스페이스 및 하위 폴더 이름을 기반으로 HF 캐시의 경로를 통일된 방식으로 생성합니다. 목표는 모든 하위 라이브러리가 자산을 자체 방식대로(예: 구조에 대한 규칙 없음) 관리할 수 있도록 하는 것입니다. 그러나 올바른 자산 폴더 내에 있어야 합니다. 그러한 라이브러리는 <code>huggingface_hub</code>의 도구를 활용하여 캐시를 관리할 수 있으며, 특히 CLI 명령을 통해 자산의 일부를 스캔하고 삭제할 수 있습니다.</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"># 자산 폴더에서 원하는 대로 작업하세요!</span><!-- HTML_TAG_END --></pre></div> <blockquote data-svelte-h="svelte-18tklt4"><p>[!TIP][cached_assets_path()](/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.cached_assets_path)는 자산을 저장하는 권장 방법이지만 필수는 아닙니다. 이미 라이브러리가 자체 캐시를 사용하는 경우 해당 캐시를 자유롭게 사용하세요!</p></blockquote> <h3 class="relative group"><a id="assets-in-practice" 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-practice"><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>자산 캐시 구조 예시</span></h3> <p data-svelte-h="svelte-nwbzz9">실제로는 자산 캐시는 다음과 같은 트리 구조를 가질 것입니다:</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="scan-your-cache" 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="#scan-your-cache"><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>캐시 확인하기</span></h2> <p data-svelte-h="svelte-khzruk">현재 캐시된 파일은 로컬 디렉토리에서 자동으로 삭제되지 않습니다. 브랜치의 새로운 수정 버전을 다운로드하면 이전 파일이 그대로 남아 향후 다시 사용할 수 있습니다. 따라서 디스크 공간을 많이 차지하는 리포지토리와 수정 버전을 파악하려면 캐시 디렉터리를 점검하는 것이 좋습니다. <code>huggingface_hub</code>은 이를 위해 CLI와 Python 유틸리티를 모두 제공합니다.</p> <h3 class="relative group"><a id="scan-cache-from-the-terminal" 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="#scan-cache-from-the-terminal"><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>터미널에서 캐시 확인하기</span></h3> <p data-svelte-h="svelte-7ecdwa">HF 캐시 상태를 살펴보는 가장 간단한 방법은 <code>hf cache ls</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 -->➜ 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-1dyulup"><code>--revisions</code> 옵션을 추가하면 각 스냅샷별 상세 목록을 확인할 수 있습니다. <code>size>1GB</code>, <code>accessed>30d</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 -->➜ 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-1ke1wrl">머신 친화적인 출력이 필요하다면 <code>--format json</code> 또는 <code>--format csv</code>를 사용하고, 식별자만 받고 싶다면 <code>--quiet</code>를 사용할 수 있습니다. <code>--cache-dir</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 -->➜ hf cache rm $(hf cache ls --filter "accessed>1y" -q) -y | |
| About to delete 2 repo(s) totalling 5.31G. | |
| - model/meta-llama/Llama-3.2-1B-Instruct (entire repo) | |
| - model/hexgrad/Kokoro-82M (entire repo) | |
| Delete repo: ~/.cache/huggingface/hub/models--meta-llama--Llama-3.2-1B-Instruct | |
| Delete repo: ~/.cache/huggingface/hub/models--hexgrad--Kokoro-82M | |
| Cache deletion done. Saved 5.31G. | |
| Deleted 2 repo(s) and 2 revision(s); freed 5.31G.<!-- HTML_TAG_END --></pre></div> <h4 class="relative group"><a id="grep-example" 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="#grep-example"><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>쉘 도구로 필터링하기</span></h4> <p data-svelte-h="svelte-1y6td3l">출력이 표 형식이므로 기존의 <code>grep</code> 같은 도구와도 잘 어울립니다. 아래 예시는 <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="scan-cache-from-python" 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="#scan-cache-from-python"><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>파이썬에서 캐시 스캔하기</span></h3> <p data-svelte-h="svelte-1054q9l">보다 고급 기능을 사용하려면, CLI 도구에서 호출되는 파이썬 유틸리티인 <a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.scan_cache_dir">scan_cache_dir()</a>을 사용할 수 있습니다.</p> <p data-svelte-h="svelte-1wrnu3y">이를 사용하여 4가지 데이터 클래스를 중심으로 구조화된 자세한 보고서를 얻을 수 있습니다:</p> <ul data-svelte-h="svelte-1ois9fk"><li><a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.HFCacheInfo">HFCacheInfo</a>: <a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.scan_cache_dir">scan_cache_dir()</a>에 의해 반환되는 완전한 보고서</li> <li><a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.CachedRepoInfo">CachedRepoInfo</a>: 캐시된 리포지토리에 관한 정보</li> <li><a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.CachedRevisionInfo">CachedRevisionInfo</a>: 리포지토리 내의 캐시된 수정 버전(예: “snapshot”)에 관한 정보</li> <li><a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.CachedFileInfo">CachedFileInfo</a>: 스냅샷 내의 캐시된 파일에 관한 정보</li></ul> <p data-svelte-h="svelte-6exgs9">다음은 간단한 사용 예시입니다. 자세한 내용은 참조 문서를 참고하세요.</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"># 수정 버전 간에 blobs가 공유되기 때문에 `last_accessed`가 없습니다.</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="clean-your-cache" 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="#clean-your-cache"><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>캐시 정리하기</span></h2> <p data-svelte-h="svelte-1h27bmw">캐시를 스캔하는 것은 흥미로울 수 있지만 실제로 해야 할 다음 작업은 일반적으로 드라이브의 일부 공간을 확보하기 위해 일부를 삭제하는 것입니다. 이는 <code>delete-cache</code> CLI 명령을 사용하여 가능합니다. 또한 캐시를 스캔할 때 반환되는 <a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.HFCacheInfo">HFCacheInfo</a> 객체에서 <a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.HFCacheInfo.delete_revisions">delete_revisions()</a> 헬퍼를 사용하여 프로그래밍 방식으로도 사용할 수 있습니다.</p> <h3 class="relative group"><a id="delete-strategy" 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="#delete-strategy"><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>전략적으로 삭제하기</span></h3> <p data-svelte-h="svelte-16fihsk">캐시를 삭제하려면 삭제할 수정 버전 목록을 전달해야 합니다. 이 도구는 이 목록을 기반으로 공간을 확보하기 위한 전략을 정의합니다. 이는 어떤 파일과 폴더가 삭제될지를 설명하는 <a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.DeleteCacheStrategy">DeleteCacheStrategy</a> 객체를 반환합니다. <a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.DeleteCacheStrategy">DeleteCacheStrategy</a>를 통해 사용 가능한 공간을 확보 할 수 있습니다. 삭제에 동의하면 삭제를 실행하여 삭제를 유효하게 만들어야 합니다. 불일치를 피하기 위해 전략 객체를 수동으로 편집할 수 없습니다.</p> <p data-svelte-h="svelte-m14rxb">수정 버전을 삭제하기 위한 전략은 다음과 같습니다:</p> <ul data-svelte-h="svelte-1gj8t4t"><li>수정 버전 심볼릭 링크가 있는 <code>snapshot</code> 폴더가 삭제됩니다.</li> <li>삭제할 수정 버전에만 대상이 되는 blobs 파일도 삭제됩니다.</li> <li>수정 버전이 1개 이상의 <code>refs</code>에 연결되어 있는 경우, 참조가 삭제됩니다.</li> <li>리포지토리의 모든 수정 버전이 삭제되는 경우 전체 캐시된 리포지토리가 삭제됩니다.</li></ul> <blockquote class="tip" data-svelte-h="svelte-13ciolr"><p>수정 버전 해시는 모든 리포지토리를 통틀어 고유합니다. 따라서 <code>hf cache rm</code>은 리포지토리 식별자(<code>model/bert-base-uncased</code> 등)와 수정 버전 해시를 모두 인수로 받으며, 해시를 전달할 때는 리포지토리를 별도로 지정할 필요가 없습니다.</p></blockquote> <blockquote class="warning" data-svelte-h="svelte-kuj1m4"><p>캐시에서 수정 버전을 찾을 수 없는 경우 무시됩니다. 또한 삭제 중에 파일 또는 폴더를 찾을 수 없는 경우 경고가 기록되지만 오류가 발생하지 않습니다. <a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.DeleteCacheStrategy">DeleteCacheStrategy</a> 객체에 포함된 다른 경로에 대해 삭제가 계속됩니다.</p></blockquote> <h3 class="relative group"><a id="clean-cache-from-the-terminal" 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="#clean-cache-from-the-terminal"><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>터미널에서 캐시 정리하기</span></h3> <p data-svelte-h="svelte-4f86g1">캐시에서 불필요한 데이터를 지우려면 <code>hf cache rm</code> 명령을 사용하세요. 리포지토리 식별자(예: <code>model/bert-base-uncased</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 -->➜ 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-1ng5d3r">여러 리포지토리와 특정 수정 버전을 함께 지정할 수도 있습니다. <code>--dry-run</code> 옵션을 사용하면 실제 삭제 없이 결과를 미리 확인할 수 있고, 자동화된 스크립트에서는 <code>--yes</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 -->➜ 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-18klubf">기본 위치가 아닌 다른 캐시 디렉터리를 다루고 있다면 <code>--cache-dir</code> 옵션으로 경로를 지정하세요.</p> <p data-svelte-h="svelte-i8j91c">사용되지 않는(detached) 스냅샷만 한 번에 정리하려면 <code>hf cache prune</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 -->➜ 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-1snorm2">두 명령 모두 <code>--dry-run</code>, <code>--yes</code>, <code>--cache-dir</code> 옵션을 지원하므로 시뮬레이션, 자동화, 대체 캐시 경로 지정을 자유롭게 조합할 수 있습니다.</p> <h3 class="relative group"><a id="clean-cache-from-python" 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="#clean-cache-from-python"><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>파이썬에서 캐시 정리하기</span></h3> <p data-svelte-h="svelte-110tg6r">더 유연하게 사용하려면, 프로그래밍 방식으로 <a href="/docs/huggingface_hub/pr_4113/ko/package_reference/cache#huggingface_hub.HFCacheInfo.delete_revisions">delete_revisions()</a> 메소드를 사용할 수도 있습니다. 간단한 예제를 살펴보겠습니다. 자세한 내용은 참조 문서를 확인하세요.</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/ko/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_1hcjqts = { | |
| assets: "/docs/huggingface_hub/pr_4113/ko", | |
| base: "/docs/huggingface_hub/pr_4113/ko", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/huggingface_hub/pr_4113/ko/_app/immutable/entry/start.e4d70577.js"), | |
| import("/docs/huggingface_hub/pr_4113/ko/_app/immutable/entry/app.3b0f3b68.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 10], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 81 kB
- Xet hash:
- c4664c7c4b7f98417d33e074d97b1b8b7501f4a0039f1da611379f36dfdbd69b
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.