Buckets:

download
raw
98.7 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;utils/model_registry&quot;,&quot;local&quot;:&quot;utilsmodelregistry&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;utils/model_registry.ModelRegistry&quot;,&quot;local&quot;:&quot;utilsmodelregistrymodelregistry&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;ModelRegistry.get_files(modelId, [options]) ⇒ Promise. < Array >&quot;,&quot;local&quot;:&quot;modelregistrygetfilesmodelid-options--promise--array-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.get_pipeline_files(task, modelId, [options]) ⇒ Promise. < Array >&quot;,&quot;local&quot;:&quot;modelregistrygetpipelinefilestask-modelid-options--promise--array-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.get_model_files(modelId, [options]) ⇒ Promise. < Array >&quot;,&quot;local&quot;:&quot;modelregistrygetmodelfilesmodelid-options--promise--array-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.get_tokenizer_files(modelId) ⇒ Promise. < Array >&quot;,&quot;local&quot;:&quot;modelregistrygettokenizerfilesmodelid--promise--array-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.get_processor_files(modelId) ⇒ Promise. < Array >&quot;,&quot;local&quot;:&quot;modelregistrygetprocessorfilesmodelid--promise--array-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.get_available_dtypes(modelId, [options]) ⇒ Promise. < Array >&quot;,&quot;local&quot;:&quot;modelregistrygetavailabledtypesmodelid-options--promise--array-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.is_cached(modelId, [options]) ⇒ Promise. < boolean >&quot;,&quot;local&quot;:&quot;modelregistryiscachedmodelid-options--promise--boolean-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.is_cached_files(modelId, [options]) ⇒ Promise. < CacheCheckResult >&quot;,&quot;local&quot;:&quot;modelregistryiscachedfilesmodelid-options--promise--cachecheckresult-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.is_pipeline_cached(task, modelId, [options]) ⇒ Promise. < boolean >&quot;,&quot;local&quot;:&quot;modelregistryispipelinecachedtask-modelid-options--promise--boolean-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.is_pipeline_cached_files(task, modelId, [options]) ⇒ Promise. < CacheCheckResult >&quot;,&quot;local&quot;:&quot;modelregistryispipelinecachedfilestask-modelid-options--promise--cachecheckresult-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.get_file_metadata(path_or_repo_id, filename, [options]) ⇒ Promise. < {exists: boolean, size: number, contentType: string, fromCache: boolean} >&quot;,&quot;local&quot;:&quot;modelregistrygetfilemetadatapathorrepoid-filename-options--promise--exists-boolean-size-number-contenttype-string-fromcache-boolean-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.clear_cache(modelId, [options]) ⇒ Promise. < CacheClearResult >&quot;,&quot;local&quot;:&quot;modelregistryclearcachemodelid-options--promise--cacheclearresult-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.clear_pipeline_cache(task, modelId, [options]) ⇒ Promise. < CacheClearResult >&quot;,&quot;local&quot;:&quot;modelregistryclearpipelinecachetask-modelid-options--promise--cacheclearresult-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2}],&quot;depth&quot;:1}">
<link href="/docs/transformers.js/pr_1649/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/entry/start.5f753a22.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/scheduler.6efaaf90.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/singletons.c0807d75.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/paths.c5938264.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/entry/app.db3dfcb7.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/preload-helper.1d8e1e5d.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/index.eb3e1f0f.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/nodes/0.1b727385.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/each.e59479a4.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/nodes/22.124f97f5.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.16f13047.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/CodeBlock.72c8dd07.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;utils/model_registry&quot;,&quot;local&quot;:&quot;utilsmodelregistry&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;utils/model_registry.ModelRegistry&quot;,&quot;local&quot;:&quot;utilsmodelregistrymodelregistry&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;ModelRegistry.get_files(modelId, [options]) ⇒ Promise. < Array >&quot;,&quot;local&quot;:&quot;modelregistrygetfilesmodelid-options--promise--array-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.get_pipeline_files(task, modelId, [options]) ⇒ Promise. < Array >&quot;,&quot;local&quot;:&quot;modelregistrygetpipelinefilestask-modelid-options--promise--array-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.get_model_files(modelId, [options]) ⇒ Promise. < Array >&quot;,&quot;local&quot;:&quot;modelregistrygetmodelfilesmodelid-options--promise--array-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.get_tokenizer_files(modelId) ⇒ Promise. < Array >&quot;,&quot;local&quot;:&quot;modelregistrygettokenizerfilesmodelid--promise--array-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.get_processor_files(modelId) ⇒ Promise. < Array >&quot;,&quot;local&quot;:&quot;modelregistrygetprocessorfilesmodelid--promise--array-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.get_available_dtypes(modelId, [options]) ⇒ Promise. < Array >&quot;,&quot;local&quot;:&quot;modelregistrygetavailabledtypesmodelid-options--promise--array-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.is_cached(modelId, [options]) ⇒ Promise. < boolean >&quot;,&quot;local&quot;:&quot;modelregistryiscachedmodelid-options--promise--boolean-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.is_cached_files(modelId, [options]) ⇒ Promise. < CacheCheckResult >&quot;,&quot;local&quot;:&quot;modelregistryiscachedfilesmodelid-options--promise--cachecheckresult-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.is_pipeline_cached(task, modelId, [options]) ⇒ Promise. < boolean >&quot;,&quot;local&quot;:&quot;modelregistryispipelinecachedtask-modelid-options--promise--boolean-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.is_pipeline_cached_files(task, modelId, [options]) ⇒ Promise. < CacheCheckResult >&quot;,&quot;local&quot;:&quot;modelregistryispipelinecachedfilestask-modelid-options--promise--cachecheckresult-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.get_file_metadata(path_or_repo_id, filename, [options]) ⇒ Promise. < {exists: boolean, size: number, contentType: string, fromCache: boolean} >&quot;,&quot;local&quot;:&quot;modelregistrygetfilemetadatapathorrepoid-filename-options--promise--exists-boolean-size-number-contenttype-string-fromcache-boolean-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.clear_cache(modelId, [options]) ⇒ Promise. < CacheClearResult >&quot;,&quot;local&quot;:&quot;modelregistryclearcachemodelid-options--promise--cacheclearresult-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ModelRegistry.clear_pipeline_cache(task, modelId, [options]) ⇒ Promise. < CacheClearResult >&quot;,&quot;local&quot;:&quot;modelregistryclearpipelinecachetask-modelid-options--promise--cacheclearresult-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <a id="module_utils/model_registry" class="group"></a> <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="utilsmodelregistry" 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="#utilsmodelregistry"><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>utils/model_registry</span></h1> <p data-svelte-h="svelte-1ysh8k8">Model registry for cache and file operations</p> <p data-svelte-h="svelte-ef8roz">Provides static methods for:</p> <ul data-svelte-h="svelte-17b0l0d"><li>Discovering which files a model needs</li> <li>Detecting available quantization levels (dtypes)</li> <li>Getting file metadata</li> <li>Checking cache status</li></ul> <p data-svelte-h="svelte-1hcetp5"><strong>Example:</strong> Get all files needed for a model</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">const</span> files = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_files</span>(
<span class="hljs-string">&quot;onnx-community/all-MiniLM-L6-v2-ONNX&quot;</span>,
{ <span class="hljs-attr">dtype</span>: <span class="hljs-string">&quot;fp16&quot;</span> },
);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(files); <span class="hljs-comment">// [ &#x27;config.json&#x27;, &#x27;onnx/model_fp16.onnx&#x27;, &#x27;onnx/model_fp16.onnx_data&#x27;, &#x27;tokenizer.json&#x27;, &#x27;tokenizer_config.json&#x27; ]</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1t21awt"><strong>Example:</strong> Get all files needed for a specific pipeline task</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">const</span> files = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_pipeline_files</span>(
<span class="hljs-string">&quot;text-generation&quot;</span>,
<span class="hljs-string">&quot;onnx-community/Qwen3-0.6B-ONNX&quot;</span>,
{ <span class="hljs-attr">dtype</span>: <span class="hljs-string">&quot;q4&quot;</span> },
);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(files); <span class="hljs-comment">// [ &#x27;config.json&#x27;, &#x27;onnx/model_q4.onnx&#x27;, &#x27;generation_config.json&#x27;, &#x27;tokenizer.json&#x27;, &#x27;tokenizer_config.json&#x27; ]</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-fgydvl"><strong>Example:</strong> Get specific component files</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">const</span> modelFiles = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_model_files</span>(<span class="hljs-string">&quot;onnx-community/all-MiniLM-L6-v2-ONNX&quot;</span>, { <span class="hljs-attr">dtype</span>: <span class="hljs-string">&quot;q4&quot;</span> });
<span class="hljs-keyword">const</span> tokenizerFiles = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_tokenizer_files</span>(<span class="hljs-string">&quot;onnx-community/all-MiniLM-L6-v2-ONNX&quot;</span>);
<span class="hljs-keyword">const</span> processorFiles = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_processor_files</span>(<span class="hljs-string">&quot;onnx-community/all-MiniLM-L6-v2-ONNX&quot;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(modelFiles); <span class="hljs-comment">// [ &#x27;config.json&#x27;, &#x27;onnx/model_q4.onnx&#x27;, &#x27;onnx/model_q4.onnx_data&#x27; ]</span>
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(tokenizerFiles); <span class="hljs-comment">// [ &#x27;tokenizer.json&#x27;, &#x27;tokenizer_config.json&#x27; ]</span>
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(processorFiles); <span class="hljs-comment">// [ ]</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-jce94a"><strong>Example:</strong> Detect available quantization levels for a model</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">const</span> dtypes = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_available_dtypes</span>(<span class="hljs-string">&quot;onnx-community/all-MiniLM-L6-v2-ONNX&quot;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(dtypes); <span class="hljs-comment">// [ &#x27;fp32&#x27;, &#x27;fp16&#x27;, &#x27;int8&#x27;, &#x27;uint8&#x27;, &#x27;q8&#x27;, &#x27;q4&#x27; ]</span>
<span class="hljs-comment">// Use the result to pick the best available dtype</span>
<span class="hljs-keyword">const</span> preferredDtype = dtypes.<span class="hljs-title function_">includes</span>(<span class="hljs-string">&quot;q4&quot;</span>) ? <span class="hljs-string">&quot;q4&quot;</span> : <span class="hljs-string">&quot;fp32&quot;</span>;
<span class="hljs-keyword">const</span> files = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_files</span>(<span class="hljs-string">&quot;onnx-community/all-MiniLM-L6-v2-ONNX&quot;</span>, { <span class="hljs-attr">dtype</span>: preferredDtype });<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-17bx9ku"><strong>Example:</strong> Check file metadata without downloading</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">const</span> metadata = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_file_metadata</span>(
<span class="hljs-string">&quot;onnx-community/Qwen3-0.6B-ONNX&quot;</span>,
<span class="hljs-string">&quot;config.json&quot;</span>
);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(metadata); <span class="hljs-comment">// { exists: true, size: 912, contentType: &#x27;application/json&#x27;, fromCache: true }</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-2tnxgf"><strong>Example:</strong> Model cache management</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">const</span> modelId = <span class="hljs-string">&quot;onnx-community/Qwen3-0.6B-ONNX&quot;</span>;
<span class="hljs-keyword">const</span> options = { <span class="hljs-attr">dtype</span>: <span class="hljs-string">&quot;q4&quot;</span> };
<span class="hljs-comment">// Quickly check if the model is cached (probably false)</span>
<span class="hljs-keyword">let</span> cached = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">is_cached</span>(modelId, options);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(cached); <span class="hljs-comment">// false</span>
<span class="hljs-comment">// Get per-file cache detail</span>
<span class="hljs-keyword">let</span> cacheStatus = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">is_cached_files</span>(modelId, options);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(cacheStatus);
<span class="hljs-comment">// {</span>
<span class="hljs-comment">// allCached: false,</span>
<span class="hljs-comment">// files: [ { file: &#x27;config.json&#x27;, cached: true }, { file: &#x27;onnx/model_q4.onnx&#x27;, cached: false }, { file: &#x27;generation_config.json&#x27;, cached: false }, { file: &#x27;tokenizer.json&#x27;, cached: false }, { file: &#x27;tokenizer_config.json&#x27;, cached: false } ]</span>
<span class="hljs-comment">// }</span>
<span class="hljs-comment">// Download the model by instantiating a pipeline</span>
<span class="hljs-keyword">const</span> generator = <span class="hljs-keyword">await</span> <span class="hljs-title function_">pipeline</span>(<span class="hljs-string">&quot;text-generation&quot;</span>, modelId, options);
<span class="hljs-keyword">const</span> output = <span class="hljs-keyword">await</span> <span class="hljs-title function_">generator</span>(
[{ <span class="hljs-attr">role</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-attr">content</span>: <span class="hljs-string">&quot;What is the capital of France?&quot;</span> }],
{ <span class="hljs-attr">max_new_tokens</span>: <span class="hljs-number">256</span>, <span class="hljs-attr">do_sample</span>: <span class="hljs-literal">false</span> },
);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(output[<span class="hljs-number">0</span>].<span class="hljs-property">generated_text</span>.<span class="hljs-title function_">at</span>(-<span class="hljs-number">1</span>).<span class="hljs-property">content</span>); <span class="hljs-comment">// &lt;think&gt;...&lt;/think&gt;\n\nThe capital of France is **Paris**.</span>
<span class="hljs-comment">// Check if the model is cached (should be true now)</span>
cached = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">is_cached</span>(modelId, options);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(cached); <span class="hljs-comment">// true</span>
<span class="hljs-comment">// Clear the cache</span>
<span class="hljs-keyword">const</span> clearResult = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">clear_cache</span>(modelId, options);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(clearResult);
<span class="hljs-comment">// {</span>
<span class="hljs-comment">// filesDeleted: 5,</span>
<span class="hljs-comment">// filesCached: 5,</span>
<span class="hljs-comment">// files: [ { file: &#x27;config.json&#x27;, deleted: true, wasCached: true }, { file: &#x27;onnx/model_q4.onnx&#x27;, deleted: true, wasCached: true }, { file: &#x27;generation_config.json&#x27;, deleted: true, wasCached: true }, { file: &#x27;tokenizer.json&#x27;, deleted: true, wasCached: true }, { file: &#x27;tokenizer_config.json&#x27;, deleted: true, wasCached: true } ]</span>
<span class="hljs-comment">// }</span>
<span class="hljs-comment">// Check if the model is cached (should be false again)</span>
cached = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">is_cached</span>(modelId, options);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(cached); <span class="hljs-comment">// false</span><!-- HTML_TAG_END --></pre></div> <ul data-svelte-h="svelte-1un3rku"><li><a href="#module_utils/model_registry">utils/model_registry</a> <ul><li><a href="#module_utils/model_registry.ModelRegistry">.ModelRegistry</a> <ul><li><a href="#module_utils/model_registry.ModelRegistry.get_files"><code>.get_files(modelId, [options])</code></a><code>Promise.&lt;Array&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.get_pipeline_files"><code>.get_pipeline_files(task, modelId, [options])</code></a><code>Promise.&lt;Array&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.get_model_files"><code>.get_model_files(modelId, [options])</code></a><code>Promise.&lt;Array&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.get_tokenizer_files"><code>.get_tokenizer_files(modelId)</code></a><code>Promise.&lt;Array&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.get_processor_files"><code>.get_processor_files(modelId)</code></a><code>Promise.&lt;Array&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.get_available_dtypes"><code>.get_available_dtypes(modelId, [options])</code></a><code>Promise.&lt;Array&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.is_cached"><code>.is_cached(modelId, [options])</code></a><code>Promise.&lt;boolean&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.is_cached_files"><code>.is_cached_files(modelId, [options])</code></a><a href="#CacheCheckResult"><code>Promise.&lt;CacheCheckResult&gt;</code></a></li> <li><a href="#module_utils/model_registry.ModelRegistry.is_pipeline_cached"><code>.is_pipeline_cached(task, modelId, [options])</code></a><code>Promise.&lt;boolean&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.is_pipeline_cached_files"><code>.is_pipeline_cached_files(task, modelId, [options])</code></a><a href="#CacheCheckResult"><code>Promise.&lt;CacheCheckResult&gt;</code></a></li> <li><a href="#module_utils/model_registry.ModelRegistry.get_file_metadata"><code>.get_file_metadata(path_or_repo_id, filename, [options])</code></a><code>Promise.&lt;{exists: boolean, size: number, contentType: string, fromCache: boolean}&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.clear_cache"><code>.clear_cache(modelId, [options])</code></a><a href="#CacheClearResult"><code>Promise.&lt;CacheClearResult&gt;</code></a></li> <li><a href="#module_utils/model_registry.ModelRegistry.clear_pipeline_cache"><code>.clear_pipeline_cache(task, modelId, [options])</code></a><a href="#CacheClearResult"><code>Promise.&lt;CacheClearResult&gt;</code></a></li></ul></li></ul></li></ul> <hr> <a id="module_utils/model_registry.ModelRegistry" class="group"></a> <h2 class="relative group"><a id="utilsmodelregistrymodelregistry" 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="#utilsmodelregistrymodelregistry"><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>utils/model_registry.ModelRegistry</span></h2> <p data-svelte-h="svelte-1kd13al">Static class for cache and file management operations.</p> <p data-svelte-h="svelte-1xzitcs"><strong>Kind</strong>: static class of <a href="#module_utils/model_registry"><code>utils/model_registry</code></a></p> <ul data-svelte-h="svelte-726o2l"><li><a href="#module_utils/model_registry.ModelRegistry">.ModelRegistry</a> <ul><li><a href="#module_utils/model_registry.ModelRegistry.get_files"><code>.get_files(modelId, [options])</code></a><code>Promise.&lt;Array&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.get_pipeline_files"><code>.get_pipeline_files(task, modelId, [options])</code></a><code>Promise.&lt;Array&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.get_model_files"><code>.get_model_files(modelId, [options])</code></a><code>Promise.&lt;Array&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.get_tokenizer_files"><code>.get_tokenizer_files(modelId)</code></a><code>Promise.&lt;Array&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.get_processor_files"><code>.get_processor_files(modelId)</code></a><code>Promise.&lt;Array&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.get_available_dtypes"><code>.get_available_dtypes(modelId, [options])</code></a><code>Promise.&lt;Array&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.is_cached"><code>.is_cached(modelId, [options])</code></a><code>Promise.&lt;boolean&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.is_cached_files"><code>.is_cached_files(modelId, [options])</code></a><a href="#CacheCheckResult"><code>Promise.&lt;CacheCheckResult&gt;</code></a></li> <li><a href="#module_utils/model_registry.ModelRegistry.is_pipeline_cached"><code>.is_pipeline_cached(task, modelId, [options])</code></a><code>Promise.&lt;boolean&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.is_pipeline_cached_files"><code>.is_pipeline_cached_files(task, modelId, [options])</code></a><a href="#CacheCheckResult"><code>Promise.&lt;CacheCheckResult&gt;</code></a></li> <li><a href="#module_utils/model_registry.ModelRegistry.get_file_metadata"><code>.get_file_metadata(path_or_repo_id, filename, [options])</code></a><code>Promise.&lt;{exists: boolean, size: number, contentType: string, fromCache: boolean}&gt;</code></li> <li><a href="#module_utils/model_registry.ModelRegistry.clear_cache"><code>.clear_cache(modelId, [options])</code></a><a href="#CacheClearResult"><code>Promise.&lt;CacheClearResult&gt;</code></a></li> <li><a href="#module_utils/model_registry.ModelRegistry.clear_pipeline_cache"><code>.clear_pipeline_cache(task, modelId, [options])</code></a><a href="#CacheClearResult"><code>Promise.&lt;CacheClearResult&gt;</code></a></li></ul></li></ul> <hr> <a id="module_utils/model_registry.ModelRegistry.get_files" class="group"></a> <h3 class="relative group"><a id="modelregistrygetfilesmodelid-options--promise--array-" 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="#modelregistrygetfilesmodelid-options--promise--array-"><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>ModelRegistry.get_files(modelId, [options]) ⇒ Promise. &lt; Array ></span></h3> <p data-svelte-h="svelte-lii7db">Get all files (model, tokenizer, processor) needed for a model.</p> <p data-svelte-h="svelte-10esqw"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;Array&gt;</code> - Array of file paths</p> <table data-svelte-h="svelte-cjikgc"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>modelId</td><td><code>string</code></td><td></td><td><p>The model id (e.g., &quot;onnx-community/bert-base-uncased-ONNX&quot;)</p></td> </tr><tr><td>[options]</td><td><code>Object</code></td><td></td><td><p>Optional parameters</p></td> </tr><tr><td>[options.config]</td><td><code><a href="#PretrainedConfig">PretrainedConfig</a></code></td><td><code></code></td><td><p>Pre-loaded config</p></td> </tr><tr><td>[options.dtype]</td><td><code><a href="#DataType">DataType</a></code> | <code>Record.&lt;string, DataType&gt;</code></td><td><code></code></td><td><p>Override dtype</p></td> </tr><tr><td>[options.device]</td><td><code><a href="#DeviceType">DeviceType</a></code> | <code>Record.&lt;string, DeviceType&gt;</code></td><td><code></code></td><td><p>Override device</p></td> </tr><tr><td>[options.model_file_name]</td><td><code>string</code></td><td><code>null</code></td><td><p>Override the model file name (excluding .onnx suffix)</p></td> </tr><tr><td>[options.include_tokenizer]</td><td><code>boolean</code></td><td><code>true</code></td><td><p>Whether to check for tokenizer files</p></td> </tr><tr><td>[options.include_processor]</td><td><code>boolean</code></td><td><code>true</code></td><td><p>Whether to check for processor files</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> files = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_files</span>(<span class="hljs-string">&#x27;onnx-community/gpt2-ONNX&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(files); <span class="hljs-comment">// [&#x27;config.json&#x27;, &#x27;tokenizer.json&#x27;, &#x27;onnx/model_q4.onnx&#x27;, ...]</span><!-- HTML_TAG_END --></pre></div> <hr> <a id="module_utils/model_registry.ModelRegistry.get_pipeline_files" class="group"></a> <h3 class="relative group"><a id="modelregistrygetpipelinefilestask-modelid-options--promise--array-" 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="#modelregistrygetpipelinefilestask-modelid-options--promise--array-"><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>ModelRegistry.get_pipeline_files(task, modelId, [options]) ⇒ Promise. &lt; Array ></span></h3> <p data-svelte-h="svelte-5jfugd">Get all files needed for a specific pipeline task.
Automatically determines which components are needed based on the task.</p> <p data-svelte-h="svelte-10esqw"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;Array&gt;</code> - Array of file paths</p> <table data-svelte-h="svelte-9tefpb"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>task</td><td><code>string</code></td><td></td><td><p>The pipeline task (e.g., &quot;text-generation&quot;, &quot;background-removal&quot;)</p></td> </tr><tr><td>modelId</td><td><code>string</code></td><td></td><td><p>The model id (e.g., &quot;onnx-community/bert-base-uncased-ONNX&quot;)</p></td> </tr><tr><td>[options]</td><td><code>Object</code></td><td></td><td><p>Optional parameters</p></td> </tr><tr><td>[options.config]</td><td><code><a href="#PretrainedConfig">PretrainedConfig</a></code></td><td><code></code></td><td><p>Pre-loaded config</p></td> </tr><tr><td>[options.dtype]</td><td><code><a href="#DataType">DataType</a></code> | <code>Record.&lt;string, DataType&gt;</code></td><td><code></code></td><td><p>Override dtype</p></td> </tr><tr><td>[options.device]</td><td><code><a href="#DeviceType">DeviceType</a></code> | <code>Record.&lt;string, DeviceType&gt;</code></td><td><code></code></td><td><p>Override device</p></td> </tr><tr><td>[options.model_file_name]</td><td><code>string</code></td><td><code>null</code></td><td><p>Override the model file name (excluding .onnx suffix)</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> files = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_pipeline_files</span>(<span class="hljs-string">&#x27;text-generation&#x27;</span>, <span class="hljs-string">&#x27;onnx-community/gpt2-ONNX&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(files); <span class="hljs-comment">// [&#x27;config.json&#x27;, &#x27;tokenizer.json&#x27;, &#x27;onnx/model_q4.onnx&#x27;, ...]</span><!-- HTML_TAG_END --></pre></div> <hr> <a id="module_utils/model_registry.ModelRegistry.get_model_files" class="group"></a> <h3 class="relative group"><a id="modelregistrygetmodelfilesmodelid-options--promise--array-" 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="#modelregistrygetmodelfilesmodelid-options--promise--array-"><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>ModelRegistry.get_model_files(modelId, [options]) ⇒ Promise. &lt; Array ></span></h3> <p data-svelte-h="svelte-1hss116">Get model files needed for a specific model.</p> <p data-svelte-h="svelte-1i2u0dx"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;Array&gt;</code> - Array of model file paths</p> <table data-svelte-h="svelte-1e6dtm2"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>modelId</td><td><code>string</code></td><td></td><td><p>The model id</p></td> </tr><tr><td>[options]</td><td><code>Object</code></td><td></td><td><p>Optional parameters</p></td> </tr><tr><td>[options.config]</td><td><code><a href="#PretrainedConfig">PretrainedConfig</a></code></td><td><code></code></td><td><p>Pre-loaded config</p></td> </tr><tr><td>[options.dtype]</td><td><code><a href="#DataType">DataType</a></code> | <code>Record.&lt;string, DataType&gt;</code></td><td><code></code></td><td><p>Override dtype</p></td> </tr><tr><td>[options.device]</td><td><code><a href="#DeviceType">DeviceType</a></code> | <code>Record.&lt;string, DeviceType&gt;</code></td><td><code></code></td><td><p>Override device</p></td> </tr><tr><td>[options.model_file_name]</td><td><code>string</code></td><td><code>null</code></td><td><p>Override the model file name (excluding .onnx suffix)</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> files = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_model_files</span>(<span class="hljs-string">&#x27;onnx-community/bert-base-uncased-ONNX&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(files); <span class="hljs-comment">// [&#x27;config.json&#x27;, &#x27;onnx/model_q4.onnx&#x27;, &#x27;generation_config.json&#x27;]</span><!-- HTML_TAG_END --></pre></div> <hr> <a id="module_utils/model_registry.ModelRegistry.get_tokenizer_files" class="group"></a> <h3 class="relative group"><a id="modelregistrygettokenizerfilesmodelid--promise--array-" 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="#modelregistrygettokenizerfilesmodelid--promise--array-"><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>ModelRegistry.get_tokenizer_files(modelId) ⇒ Promise. &lt; Array ></span></h3> <p data-svelte-h="svelte-19jkoey">Get tokenizer files needed for a specific model.</p> <p data-svelte-h="svelte-glmqu5"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;Array&gt;</code> - Array of tokenizer file paths</p> <table data-svelte-h="svelte-e2047x"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>modelId</td><td><code>string</code></td><td><p>The model id</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> files = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_tokenizer_files</span>(<span class="hljs-string">&#x27;onnx-community/gpt2-ONNX&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(files); <span class="hljs-comment">// [&#x27;tokenizer.json&#x27;, &#x27;tokenizer_config.json&#x27;]</span><!-- HTML_TAG_END --></pre></div> <hr> <a id="module_utils/model_registry.ModelRegistry.get_processor_files" class="group"></a> <h3 class="relative group"><a id="modelregistrygetprocessorfilesmodelid--promise--array-" 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="#modelregistrygetprocessorfilesmodelid--promise--array-"><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>ModelRegistry.get_processor_files(modelId) ⇒ Promise. &lt; Array ></span></h3> <p data-svelte-h="svelte-nfbbaz">Get processor files needed for a specific model.</p> <p data-svelte-h="svelte-paishs"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;Array&gt;</code> - Array of processor file paths</p> <table data-svelte-h="svelte-e2047x"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>modelId</td><td><code>string</code></td><td><p>The model id</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> files = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_processor_files</span>(<span class="hljs-string">&#x27;onnx-community/vit-base-patch16-224-ONNX&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(files); <span class="hljs-comment">// [&#x27;preprocessor_config.json&#x27;]</span><!-- HTML_TAG_END --></pre></div> <hr> <a id="module_utils/model_registry.ModelRegistry.get_available_dtypes" class="group"></a> <h3 class="relative group"><a id="modelregistrygetavailabledtypesmodelid-options--promise--array-" 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="#modelregistrygetavailabledtypesmodelid-options--promise--array-"><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>ModelRegistry.get_available_dtypes(modelId, [options]) ⇒ Promise. &lt; Array ></span></h3> <p data-svelte-h="svelte-gkw8ba">Detects which quantization levels (dtypes) are available for a model
by checking which ONNX files exist on the hub or locally.</p> <p data-svelte-h="svelte-j7xapm">A dtype is considered available if all required model session files
exist for that dtype.</p> <p data-svelte-h="svelte-405eb6"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;Array&gt;</code> - Array of available dtype strings (e.g., [‘fp32’, ‘fp16’, ‘q4’, ‘q8’])</p> <table data-svelte-h="svelte-itvblz"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>modelId</td><td><code>string</code></td><td></td><td><p>The model id (e.g., &quot;onnx-community/all-MiniLM-L6-v2-ONNX&quot;)</p></td> </tr><tr><td>[options]</td><td><code>Object</code></td><td></td><td><p>Optional parameters</p></td> </tr><tr><td>[options.config]</td><td><code><a href="#PretrainedConfig">PretrainedConfig</a></code></td><td><code></code></td><td><p>Pre-loaded config</p></td> </tr><tr><td>[options.model_file_name]</td><td><code>string</code></td><td><code>null</code></td><td><p>Override the model file name (excluding .onnx suffix)</p></td> </tr><tr><td>[options.revision]</td><td><code>string</code></td><td><code>&quot;&#39;main&#39;&quot;</code></td><td><p>Model revision</p></td> </tr><tr><td>[options.cache_dir]</td><td><code>string</code></td><td><code>null</code></td><td><p>Custom cache directory</p></td> </tr><tr><td>[options.local_files_only]</td><td><code>boolean</code></td><td><code>false</code></td><td><p>Only check local files</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> dtypes = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_available_dtypes</span>(<span class="hljs-string">&#x27;onnx-community/all-MiniLM-L6-v2-ONNX&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(dtypes); <span class="hljs-comment">// [&#x27;fp32&#x27;, &#x27;fp16&#x27;, &#x27;int8&#x27;, &#x27;uint8&#x27;, &#x27;q8&#x27;, &#x27;q4&#x27;]</span><!-- HTML_TAG_END --></pre></div> <hr> <a id="module_utils/model_registry.ModelRegistry.is_cached" class="group"></a> <h3 class="relative group"><a id="modelregistryiscachedmodelid-options--promise--boolean-" 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="#modelregistryiscachedmodelid-options--promise--boolean-"><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>ModelRegistry.is_cached(modelId, [options]) ⇒ Promise. &lt; boolean ></span></h3> <p data-svelte-h="svelte-145ques">Quickly checks if a model is fully cached by verifying <code>config.json</code> is present,
then confirming all required files are cached.
Returns a plain boolean — use <code>is_cached_files</code> if you need per-file detail.</p> <p data-svelte-h="svelte-181bw87"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;boolean&gt;</code> - Whether all required files are cached</p> <table data-svelte-h="svelte-74nxki"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>modelId</td><td><code>string</code></td><td></td><td><p>The model id</p></td> </tr><tr><td>[options]</td><td><code>Object</code></td><td></td><td><p>Optional parameters</p></td> </tr><tr><td>[options.cache_dir]</td><td><code>string</code></td><td></td><td><p>Custom cache directory</p></td> </tr><tr><td>[options.revision]</td><td><code>string</code></td><td></td><td><p>Model revision (default: &#39;main&#39;)</p></td> </tr><tr><td>[options.config]</td><td><code><a href="#PretrainedConfig">PretrainedConfig</a></code></td><td></td><td><p>Pre-loaded config</p></td> </tr><tr><td>[options.dtype]</td><td><code><a href="#DataType">DataType</a></code> | <code>Record.&lt;string, DataType&gt;</code></td><td><code></code></td><td><p>Override dtype</p></td> </tr><tr><td>[options.device]</td><td><code><a href="#DeviceType">DeviceType</a></code> | <code>Record.&lt;string, DeviceType&gt;</code></td><td><code></code></td><td><p>Override device</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> cached = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">is_cached</span>(<span class="hljs-string">&#x27;onnx-community/bert-base-uncased-ONNX&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(cached); <span class="hljs-comment">// true or false</span><!-- HTML_TAG_END --></pre></div> <hr> <a id="module_utils/model_registry.ModelRegistry.is_cached_files" class="group"></a> <h3 class="relative group"><a id="modelregistryiscachedfilesmodelid-options--promise--cachecheckresult-" 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="#modelregistryiscachedfilesmodelid-options--promise--cachecheckresult-"><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>ModelRegistry.is_cached_files(modelId, [options]) ⇒ Promise. &lt; CacheCheckResult ></span></h3> <p data-svelte-h="svelte-73r79c">Checks if all files for a given model are already cached, with per-file detail.
Automatically determines which files are needed using get_files().</p> <p data-svelte-h="svelte-njpepu"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <a href="#CacheCheckResult"><code>Promise.&lt;CacheCheckResult&gt;</code></a> - Object with allCached boolean and files array with cache status</p> <table data-svelte-h="svelte-74nxki"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>modelId</td><td><code>string</code></td><td></td><td><p>The model id</p></td> </tr><tr><td>[options]</td><td><code>Object</code></td><td></td><td><p>Optional parameters</p></td> </tr><tr><td>[options.cache_dir]</td><td><code>string</code></td><td></td><td><p>Custom cache directory</p></td> </tr><tr><td>[options.revision]</td><td><code>string</code></td><td></td><td><p>Model revision (default: &#39;main&#39;)</p></td> </tr><tr><td>[options.config]</td><td><code><a href="#PretrainedConfig">PretrainedConfig</a></code></td><td></td><td><p>Pre-loaded config</p></td> </tr><tr><td>[options.dtype]</td><td><code><a href="#DataType">DataType</a></code> | <code>Record.&lt;string, DataType&gt;</code></td><td><code></code></td><td><p>Override dtype</p></td> </tr><tr><td>[options.device]</td><td><code><a href="#DeviceType">DeviceType</a></code> | <code>Record.&lt;string, DeviceType&gt;</code></td><td><code></code></td><td><p>Override device</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> status = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">is_cached_files</span>(<span class="hljs-string">&#x27;onnx-community/bert-base-uncased-ONNX&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(status.<span class="hljs-property">allCached</span>); <span class="hljs-comment">// true or false</span>
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(status.<span class="hljs-property">files</span>); <span class="hljs-comment">// [{ file: &#x27;config.json&#x27;, cached: true }, ...]</span><!-- HTML_TAG_END --></pre></div> <hr> <a id="module_utils/model_registry.ModelRegistry.is_pipeline_cached" class="group"></a> <h3 class="relative group"><a id="modelregistryispipelinecachedtask-modelid-options--promise--boolean-" 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="#modelregistryispipelinecachedtask-modelid-options--promise--boolean-"><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>ModelRegistry.is_pipeline_cached(task, modelId, [options]) ⇒ Promise. &lt; boolean ></span></h3> <p data-svelte-h="svelte-sv13fs">Quickly checks if all files for a specific pipeline task are cached by verifying
<code>config.json</code> is present, then confirming all required files are cached.
Returns a plain boolean — use <code>is_pipeline_cached_files</code> if you need per-file detail.</p> <p data-svelte-h="svelte-181bw87"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;boolean&gt;</code> - Whether all required files are cached</p> <table data-svelte-h="svelte-4lhju7"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>task</td><td><code>string</code></td><td></td><td><p>The pipeline task (e.g., &quot;text-generation&quot;, &quot;background-removal&quot;)</p></td> </tr><tr><td>modelId</td><td><code>string</code></td><td></td><td><p>The model id</p></td> </tr><tr><td>[options]</td><td><code>Object</code></td><td></td><td><p>Optional parameters</p></td> </tr><tr><td>[options.cache_dir]</td><td><code>string</code></td><td></td><td><p>Custom cache directory</p></td> </tr><tr><td>[options.revision]</td><td><code>string</code></td><td></td><td><p>Model revision (default: &#39;main&#39;)</p></td> </tr><tr><td>[options.config]</td><td><code><a href="#PretrainedConfig">PretrainedConfig</a></code></td><td></td><td><p>Pre-loaded config</p></td> </tr><tr><td>[options.dtype]</td><td><code><a href="#DataType">DataType</a></code> | <code>Record.&lt;string, DataType&gt;</code></td><td><code></code></td><td><p>Override dtype</p></td> </tr><tr><td>[options.device]</td><td><code><a href="#DeviceType">DeviceType</a></code> | <code>Record.&lt;string, DeviceType&gt;</code></td><td><code></code></td><td><p>Override device</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> cached = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">is_pipeline_cached</span>(<span class="hljs-string">&#x27;text-generation&#x27;</span>, <span class="hljs-string">&#x27;onnx-community/gpt2-ONNX&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(cached); <span class="hljs-comment">// true or false</span><!-- HTML_TAG_END --></pre></div> <hr> <a id="module_utils/model_registry.ModelRegistry.is_pipeline_cached_files" class="group"></a> <h3 class="relative group"><a id="modelregistryispipelinecachedfilestask-modelid-options--promise--cachecheckresult-" 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="#modelregistryispipelinecachedfilestask-modelid-options--promise--cachecheckresult-"><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>ModelRegistry.is_pipeline_cached_files(task, modelId, [options]) ⇒ Promise. &lt; CacheCheckResult ></span></h3> <p data-svelte-h="svelte-x8opf5">Checks if all files for a specific pipeline task are already cached, with per-file detail.
Automatically determines which components are needed based on the task.</p> <p data-svelte-h="svelte-njpepu"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <a href="#CacheCheckResult"><code>Promise.&lt;CacheCheckResult&gt;</code></a> - Object with allCached boolean and files array with cache status</p> <table data-svelte-h="svelte-4lhju7"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>task</td><td><code>string</code></td><td></td><td><p>The pipeline task (e.g., &quot;text-generation&quot;, &quot;background-removal&quot;)</p></td> </tr><tr><td>modelId</td><td><code>string</code></td><td></td><td><p>The model id</p></td> </tr><tr><td>[options]</td><td><code>Object</code></td><td></td><td><p>Optional parameters</p></td> </tr><tr><td>[options.cache_dir]</td><td><code>string</code></td><td></td><td><p>Custom cache directory</p></td> </tr><tr><td>[options.revision]</td><td><code>string</code></td><td></td><td><p>Model revision (default: &#39;main&#39;)</p></td> </tr><tr><td>[options.config]</td><td><code><a href="#PretrainedConfig">PretrainedConfig</a></code></td><td></td><td><p>Pre-loaded config</p></td> </tr><tr><td>[options.dtype]</td><td><code><a href="#DataType">DataType</a></code> | <code>Record.&lt;string, DataType&gt;</code></td><td><code></code></td><td><p>Override dtype</p></td> </tr><tr><td>[options.device]</td><td><code><a href="#DeviceType">DeviceType</a></code> | <code>Record.&lt;string, DeviceType&gt;</code></td><td><code></code></td><td><p>Override device</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> status = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">is_pipeline_cached_files</span>(<span class="hljs-string">&#x27;text-generation&#x27;</span>, <span class="hljs-string">&#x27;onnx-community/gpt2-ONNX&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(status.<span class="hljs-property">allCached</span>); <span class="hljs-comment">// true or false</span>
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(status.<span class="hljs-property">files</span>); <span class="hljs-comment">// [{ file: &#x27;config.json&#x27;, cached: true }, ...]</span><!-- HTML_TAG_END --></pre></div> <hr> <a id="module_utils/model_registry.ModelRegistry.get_file_metadata" class="group"></a> <h3 class="relative group"><a id="modelregistrygetfilemetadatapathorrepoid-filename-options--promise--exists-boolean-size-number-contenttype-string-fromcache-boolean-" 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="#modelregistrygetfilemetadatapathorrepoid-filename-options--promise--exists-boolean-size-number-contenttype-string-fromcache-boolean-"><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>ModelRegistry.get_file_metadata(path_or_repo_id, filename, [options]) ⇒ Promise. &lt; {exists: boolean, size: number, contentType: string, fromCache: boolean} ></span></h3> <p data-svelte-h="svelte-q41ox2">Get metadata for a specific file without downloading it.</p> <p data-svelte-h="svelte-1h9tx0v"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;{exists: boolean, size: number, contentType: string, fromCache: boolean}&gt;</code> - File metadata</p> <table data-svelte-h="svelte-1720tdq"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>path_or_repo_id</td><td><code>string</code></td><td><p>Model id or path</p></td> </tr><tr><td>filename</td><td><code>string</code></td><td><p>The file name</p></td> </tr><tr><td>[options]</td><td><code><a href="#PretrainedOptions">PretrainedOptions</a></code></td><td><p>Optional parameters</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> metadata = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">get_file_metadata</span>(<span class="hljs-string">&#x27;onnx-community/gpt2-ONNX&#x27;</span>, <span class="hljs-string">&#x27;config.json&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(metadata.<span class="hljs-property">exists</span>, metadata.<span class="hljs-property">size</span>); <span class="hljs-comment">// true, 665</span><!-- HTML_TAG_END --></pre></div> <hr> <a id="module_utils/model_registry.ModelRegistry.clear_cache" class="group"></a> <h3 class="relative group"><a id="modelregistryclearcachemodelid-options--promise--cacheclearresult-" 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="#modelregistryclearcachemodelid-options--promise--cacheclearresult-"><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>ModelRegistry.clear_cache(modelId, [options]) ⇒ Promise. &lt; CacheClearResult ></span></h3> <p data-svelte-h="svelte-1m87x63">Clears all cached files for a given model.
Automatically determines which files are needed and removes them from the cache.</p> <p data-svelte-h="svelte-1d4efca"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <a href="#CacheClearResult"><code>Promise.&lt;CacheClearResult&gt;</code></a> - Object with deletion statistics and file status</p> <table data-svelte-h="svelte-uyxuv0"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>modelId</td><td><code>string</code></td><td></td><td><p>The model id (e.g., &quot;onnx-community/gpt2-ONNX&quot;)</p></td> </tr><tr><td>[options]</td><td><code>Object</code></td><td></td><td><p>Optional parameters</p></td> </tr><tr><td>[options.cache_dir]</td><td><code>string</code></td><td></td><td><p>Custom cache directory</p></td> </tr><tr><td>[options.revision]</td><td><code>string</code></td><td></td><td><p>Model revision (default: &#39;main&#39;)</p></td> </tr><tr><td>[options.config]</td><td><code><a href="#PretrainedConfig">PretrainedConfig</a></code></td><td></td><td><p>Pre-loaded config</p></td> </tr><tr><td>[options.dtype]</td><td><code><a href="#DataType">DataType</a></code> | <code>Record.&lt;string, DataType&gt;</code></td><td></td><td><p>Override dtype</p></td> </tr><tr><td>[options.device]</td><td><code><a href="#DeviceType">DeviceType</a></code> | <code>Record.&lt;string, DeviceType&gt;</code></td><td></td><td><p>Override device</p></td> </tr><tr><td>[options.include_tokenizer]</td><td><code>boolean</code></td><td><code>true</code></td><td><p>Whether to clear tokenizer files</p></td> </tr><tr><td>[options.include_processor]</td><td><code>boolean</code></td><td><code>true</code></td><td><p>Whether to clear processor files</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> result = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">clear_cache</span>(<span class="hljs-string">&#x27;onnx-community/bert-base-uncased-ONNX&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">`Deleted <span class="hljs-subst">${result.filesDeleted}</span> of <span class="hljs-subst">${result.filesCached}</span> cached files`</span>);<!-- HTML_TAG_END --></pre></div> <hr> <a id="module_utils/model_registry.ModelRegistry.clear_pipeline_cache" class="group"></a> <h3 class="relative group"><a id="modelregistryclearpipelinecachetask-modelid-options--promise--cacheclearresult-" 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="#modelregistryclearpipelinecachetask-modelid-options--promise--cacheclearresult-"><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>ModelRegistry.clear_pipeline_cache(task, modelId, [options]) ⇒ Promise. &lt; CacheClearResult ></span></h3> <p data-svelte-h="svelte-8fr5k0">Clears all cached files for a specific pipeline task.
Automatically determines which components are needed based on the task.</p> <p data-svelte-h="svelte-1d4efca"><strong>Kind</strong>: static method of <a href="#module_utils/model_registry.ModelRegistry"><code>ModelRegistry</code></a><br> <strong>Returns</strong>: <a href="#CacheClearResult"><code>Promise.&lt;CacheClearResult&gt;</code></a> - Object with deletion statistics and file status</p> <table data-svelte-h="svelte-69a3s2"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>task</td><td><code>string</code></td><td><p>The pipeline task (e.g., &quot;text-generation&quot;, &quot;image-classification&quot;)</p></td> </tr><tr><td>modelId</td><td><code>string</code></td><td><p>The model id (e.g., &quot;onnx-community/gpt2-ONNX&quot;)</p></td> </tr><tr><td>[options]</td><td><code>Object</code></td><td><p>Optional parameters</p></td> </tr><tr><td>[options.cache_dir]</td><td><code>string</code></td><td><p>Custom cache directory</p></td> </tr><tr><td>[options.revision]</td><td><code>string</code></td><td><p>Model revision (default: &#39;main&#39;)</p></td> </tr><tr><td>[options.config]</td><td><code><a href="#PretrainedConfig">PretrainedConfig</a></code></td><td><p>Pre-loaded config</p></td> </tr><tr><td>[options.dtype]</td><td><code><a href="#DataType">DataType</a></code> | <code>Record.&lt;string, DataType&gt;</code></td><td><p>Override dtype</p></td> </tr><tr><td>[options.device]</td><td><code><a href="#DeviceType">DeviceType</a></code> | <code>Record.&lt;string, DeviceType&gt;</code></td><td><p>Override device</p></td></tr></tbody></table> <p data-svelte-h="svelte-1aswmub"><strong>Example</strong></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">const</span> result = <span class="hljs-keyword">await</span> <span class="hljs-title class_">ModelRegistry</span>.<span class="hljs-title function_">clear_pipeline_cache</span>(<span class="hljs-string">&#x27;text-generation&#x27;</span>, <span class="hljs-string">&#x27;onnx-community/gpt2-ONNX&#x27;</span>);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">`Deleted <span class="hljs-subst">${result.filesDeleted}</span> of <span class="hljs-subst">${result.filesCached}</span> cached files`</span>);<!-- HTML_TAG_END --></pre></div> <hr> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/transformers.js/blob/main/packages/transformers/docs/source/api/utils/model_registry.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_rvrl7f = {
assets: "/docs/transformers.js/pr_1649/en",
base: "/docs/transformers.js/pr_1649/en",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/transformers.js/pr_1649/en/_app/immutable/entry/start.5f753a22.js"),
import("/docs/transformers.js/pr_1649/en/_app/immutable/entry/app.db3dfcb7.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 22],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
98.7 kB
·
Xet hash:
1d68e342a201ded5a8a9bf4f96b74b4a80fa65cec26c1003e688fb661bf28d40

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.