Buckets:

download
raw
58.3 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;utils/hub&quot;,&quot;local&quot;:&quot;utilshub&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;utils/hub.getFile(urlOrPath) ⇒ Promise. < (FileResponse|Response) >&quot;,&quot;local&quot;:&quot;utilshubgetfileurlorpath--promise--fileresponseresponse-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.getFetchHeaders(urlOrPath) ⇒ Headers&quot;,&quot;local&quot;:&quot;utilshubgetfetchheadersurlorpath--headers&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.buildResourcePaths(path_or_repo_id, filename, [options], [cache]) ⇒ Object&quot;,&quot;local&quot;:&quot;utilshubbuildresourcepathspathorrepoid-filename-options-cache--object&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.checkCachedResource(cache, localPath, proposedCacheKey) ⇒ Promise. < (Response|FileResponse|undefined|string) >&quot;,&quot;local&quot;:&quot;utilshubcheckcachedresourcecache-localpath-proposedcachekey--promise--responsefileresponseundefinedstring-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.storeCachedResource(path_or_repo_id, filename, cache, cacheKey, response, [result], [options]) ⇒ Promise. < void >&quot;,&quot;local&quot;:&quot;utilshubstorecachedresourcepathorrepoid-filename-cache-cachekey-response-result-options--promise--void-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.loadResourceFile(path_or_repo_id, filename, [fatal], [options], [return_path], [cache]) ⇒ Promise. < (string|Uint8Array|null) >&quot;,&quot;local&quot;:&quot;utilshubloadresourcefilepathorrepoid-filename-fatal-options-returnpath-cache--promise--stringuint8arraynull-&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;loadResourceFile~cacheKey : string&quot;,&quot;local&quot;:&quot;loadresourcefilecachekey--string&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;loadResourceFile~response : Response | FileResponse | undefined | string&quot;,&quot;local&quot;:&quot;loadresourcefileresponse--response--fileresponse--undefined--string&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;loadResourceFile~buffer : Uint8Array&quot;,&quot;local&quot;:&quot;loadresourcefilebuffer--uint8array&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.getModelFile(path_or_repo_id, filename, [fatal], [options], [return_path]) ⇒ Promise. < (string|Uint8Array) >&quot;,&quot;local&quot;:&quot;utilshubgetmodelfilepathorrepoid-filename-fatal-options-returnpath--promise--stringuint8array-&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;getModelFile~cache : CacheInterface | null&quot;,&quot;local&quot;:&quot;getmodelfilecache--cacheinterface--null&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.getModelText(modelPath, fileName, [fatal], [options]) ⇒ Promise. < (string|null) >&quot;,&quot;local&quot;:&quot;utilshubgetmodeltextmodelpath-filename-fatal-options--promise--stringnull-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.getModelJSON(modelPath, fileName, [fatal], [options]) ⇒ Promise. < Object >&quot;,&quot;local&quot;:&quot;utilshubgetmodeljsonmodelpath-filename-fatal-options--promise--object-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub~INFLIGHT_LOADS : Map. < string, Promise. < (string|Uint8Array) > >&quot;,&quot;local&quot;:&quot;utilshubinflightloads--map--string-promise--stringuint8array--&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub~ExternalData : boolean | number&quot;,&quot;local&quot;:&quot;utilshubexternaldata--boolean--number&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub~PretrainedOptions : Object&quot;,&quot;local&quot;:&quot;utilshubpretrainedoptions--object&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub~ModelSpecificPretrainedOptions : Object&quot;,&quot;local&quot;:&quot;utilshubmodelspecificpretrainedoptions--object&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub~PretrainedModelOptions : PretrainedOptions | ModelSpecificPretrainedOptions&quot;,&quot;local&quot;:&quot;utilshubpretrainedmodeloptions--pretrainedoptions--modelspecificpretrainedoptions&quot;,&quot;sections&quot;:[],&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/18.bb1f7118.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1649/en/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.16f13047.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;utils/hub&quot;,&quot;local&quot;:&quot;utilshub&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;utils/hub.getFile(urlOrPath) ⇒ Promise. < (FileResponse|Response) >&quot;,&quot;local&quot;:&quot;utilshubgetfileurlorpath--promise--fileresponseresponse-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.getFetchHeaders(urlOrPath) ⇒ Headers&quot;,&quot;local&quot;:&quot;utilshubgetfetchheadersurlorpath--headers&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.buildResourcePaths(path_or_repo_id, filename, [options], [cache]) ⇒ Object&quot;,&quot;local&quot;:&quot;utilshubbuildresourcepathspathorrepoid-filename-options-cache--object&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.checkCachedResource(cache, localPath, proposedCacheKey) ⇒ Promise. < (Response|FileResponse|undefined|string) >&quot;,&quot;local&quot;:&quot;utilshubcheckcachedresourcecache-localpath-proposedcachekey--promise--responsefileresponseundefinedstring-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.storeCachedResource(path_or_repo_id, filename, cache, cacheKey, response, [result], [options]) ⇒ Promise. < void >&quot;,&quot;local&quot;:&quot;utilshubstorecachedresourcepathorrepoid-filename-cache-cachekey-response-result-options--promise--void-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.loadResourceFile(path_or_repo_id, filename, [fatal], [options], [return_path], [cache]) ⇒ Promise. < (string|Uint8Array|null) >&quot;,&quot;local&quot;:&quot;utilshubloadresourcefilepathorrepoid-filename-fatal-options-returnpath-cache--promise--stringuint8arraynull-&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;loadResourceFile~cacheKey : string&quot;,&quot;local&quot;:&quot;loadresourcefilecachekey--string&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;loadResourceFile~response : Response | FileResponse | undefined | string&quot;,&quot;local&quot;:&quot;loadresourcefileresponse--response--fileresponse--undefined--string&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;loadResourceFile~buffer : Uint8Array&quot;,&quot;local&quot;:&quot;loadresourcefilebuffer--uint8array&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.getModelFile(path_or_repo_id, filename, [fatal], [options], [return_path]) ⇒ Promise. < (string|Uint8Array) >&quot;,&quot;local&quot;:&quot;utilshubgetmodelfilepathorrepoid-filename-fatal-options-returnpath--promise--stringuint8array-&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;getModelFile~cache : CacheInterface | null&quot;,&quot;local&quot;:&quot;getmodelfilecache--cacheinterface--null&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.getModelText(modelPath, fileName, [fatal], [options]) ⇒ Promise. < (string|null) >&quot;,&quot;local&quot;:&quot;utilshubgetmodeltextmodelpath-filename-fatal-options--promise--stringnull-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub.getModelJSON(modelPath, fileName, [fatal], [options]) ⇒ Promise. < Object >&quot;,&quot;local&quot;:&quot;utilshubgetmodeljsonmodelpath-filename-fatal-options--promise--object-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub~INFLIGHT_LOADS : Map. < string, Promise. < (string|Uint8Array) > >&quot;,&quot;local&quot;:&quot;utilshubinflightloads--map--string-promise--stringuint8array--&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub~ExternalData : boolean | number&quot;,&quot;local&quot;:&quot;utilshubexternaldata--boolean--number&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub~PretrainedOptions : Object&quot;,&quot;local&quot;:&quot;utilshubpretrainedoptions--object&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub~ModelSpecificPretrainedOptions : Object&quot;,&quot;local&quot;:&quot;utilshubmodelspecificpretrainedoptions--object&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;utils/hub~PretrainedModelOptions : PretrainedOptions | ModelSpecificPretrainedOptions&quot;,&quot;local&quot;:&quot;utilshubpretrainedmodeloptions--pretrainedoptions--modelspecificpretrainedoptions&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <a id="module_utils/hub" 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="utilshub" 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="#utilshub"><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/hub</span></h1> <p data-svelte-h="svelte-1jxl61c">Utility functions to interact with the Hugging Face Hub (<a href="https://huggingface.co/models" rel="nofollow">https://huggingface.co/models</a>)</p> <ul data-svelte-h="svelte-7guav0"><li><a href="#module_utils/hub">utils/hub</a> <ul><li><em>static</em> <ul><li><a href="#module_utils/hub.getFile"><code>.getFile(urlOrPath)</code></a><code>Promise.&lt;(FileResponse|Response)&gt;</code></li> <li><a href="#module_utils/hub.getFetchHeaders"><code>.getFetchHeaders(urlOrPath)</code></a><code>Headers</code></li> <li><a href="#module_utils/hub.buildResourcePaths"><code>.buildResourcePaths(path_or_repo_id, filename, [options], [cache])</code></a><code>Object</code></li> <li><a href="#module_utils/hub.checkCachedResource"><code>.checkCachedResource(cache, localPath, proposedCacheKey)</code></a><code>Promise.&lt;(Response|FileResponse|undefined|string)&gt;</code></li> <li><a href="#module_utils/hub.storeCachedResource"><code>.storeCachedResource(path_or_repo_id, filename, cache, cacheKey, response, [result], [options])</code></a><code>Promise.&lt;void&gt;</code></li> <li><a href="#module_utils/hub.loadResourceFile"><code>.loadResourceFile(path_or_repo_id, filename, [fatal], [options], [return_path], [cache])</code></a><code>Promise.&lt;(string|Uint8Array|null)&gt;</code> <ul><li><a href="#module_utils/hub.loadResourceFile..cacheKey"><code>~cacheKey</code></a> : <code>string</code></li> <li><a href="#module_utils/hub.loadResourceFile..response"><code>~response</code></a> : <code>Response</code> | <code>FileResponse</code> | <code>undefined</code> | <code>string</code></li> <li><a href="#module_utils/hub.loadResourceFile..buffer"><code>~buffer</code></a> : <code>Uint8Array</code></li></ul></li> <li><a href="#module_utils/hub.getModelFile"><code>.getModelFile(path_or_repo_id, filename, [fatal], [options], [return_path])</code></a><code>Promise.&lt;(string|Uint8Array)&gt;</code> <ul><li><a href="#module_utils/hub.getModelFile..cache"><code>~cache</code></a> : <a href="#CacheInterface"><code>CacheInterface</code></a> | <code>null</code></li></ul></li> <li><a href="#module_utils/hub.getModelText"><code>.getModelText(modelPath, fileName, [fatal], [options])</code></a><code>Promise.&lt;(string|null)&gt;</code></li> <li><a href="#module_utils/hub.getModelJSON"><code>.getModelJSON(modelPath, fileName, [fatal], [options])</code></a><code>Promise.&lt;Object&gt;</code></li></ul></li> <li><em>inner</em> <ul><li><a href="#module_utils/hub..INFLIGHT_LOADS"><code>~INFLIGHT_LOADS</code></a> : <code>Map.&lt;string, Promise.&lt;(string|Uint8Array)&gt;&gt;</code></li> <li><a href="#module_utils/hub..ExternalData"><code>~ExternalData</code></a> : <code>boolean</code> | <code>number</code></li> <li><a href="#module_utils/hub..PretrainedOptions"><code>~PretrainedOptions</code></a> : <code>Object</code></li> <li><a href="#module_utils/hub..ModelSpecificPretrainedOptions"><code>~ModelSpecificPretrainedOptions</code></a> : <code>Object</code></li> <li><a href="#module_utils/hub..PretrainedModelOptions"><code>~PretrainedModelOptions</code></a> : <a href="#PretrainedOptions"><code>PretrainedOptions</code></a> | <code>ModelSpecificPretrainedOptions</code></li></ul></li></ul></li></ul> <hr> <a id="module_utils/hub.getFile" class="group"></a> <h2 class="relative group"><a id="utilshubgetfileurlorpath--promise--fileresponseresponse-" 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="#utilshubgetfileurlorpath--promise--fileresponseresponse-"><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/hub.getFile(urlOrPath) ⇒ Promise. &lt; (FileResponse|Response) ></span></h2> <p data-svelte-h="svelte-10mshiw">Helper function to get a file, using either the Fetch API or FileSystem API.</p> <p data-svelte-h="svelte-1jj7eze"><strong>Kind</strong>: static method of <a href="#module_utils/hub"><code>utils/hub</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;(FileResponse|Response)&gt;</code> - A promise that resolves to a FileResponse object (if the file is retrieved using the FileSystem API), or a Response object (if the file is retrieved using the Fetch API).</p> <table data-svelte-h="svelte-pbwhgs"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>urlOrPath</td><td><code>URL</code> | <code>string</code></td><td><p>The URL/path of the file to get.</p></td></tr></tbody></table> <hr> <a id="module_utils/hub.getFetchHeaders" class="group"></a> <h2 class="relative group"><a id="utilshubgetfetchheadersurlorpath--headers" 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="#utilshubgetfetchheadersurlorpath--headers"><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/hub.getFetchHeaders(urlOrPath) ⇒ Headers</span></h2> <p data-svelte-h="svelte-1od48qt">Generates appropriate HTTP headers for fetching resources.
In Node.js environments, adds User-Agent and Authorization headers when applicable.
In browser environments, returns minimal headers for security.</p> <p data-svelte-h="svelte-royax1"><strong>Kind</strong>: static method of <a href="#module_utils/hub"><code>utils/hub</code></a><br> <strong>Returns</strong>: <code>Headers</code> - A Headers object with appropriate headers for the request.</p> <table data-svelte-h="svelte-1mfnt0l"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>urlOrPath</td><td><code>URL</code> | <code>string</code></td><td><p>The URL or path being fetched.</p></td></tr></tbody></table> <hr> <a id="module_utils/hub.buildResourcePaths" class="group"></a> <h2 class="relative group"><a id="utilshubbuildresourcepathspathorrepoid-filename-options-cache--object" 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="#utilshubbuildresourcepathspathorrepoid-filename-options-cache--object"><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/hub.buildResourcePaths(path_or_repo_id, filename, [options], [cache]) ⇒ Object</span></h2> <p data-svelte-h="svelte-177s8xo">Builds the resource paths and URLs for a model file.
Can be used to get the resource URL or path without loading the file.</p> <p data-svelte-h="svelte-w8kobv"><strong>Kind</strong>: static method of <a href="#module_utils/hub"><code>utils/hub</code></a><br> <strong>Returns</strong>: <code>Object</code> - An object containing all the paths and URLs for the resource.</p> <table data-svelte-h="svelte-1ve8itn"><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>This can be either:</p> <ul><li>a string, the <em>model id</em> of a model repo on huggingface.co.</li> <li>a path to a <em>directory</em> potentially containing the file.</li></ul></td> </tr><tr><td>filename</td><td><code>string</code></td><td><p>The name of the file to locate.</p></td> </tr><tr><td>[options]</td><td><code><a href="#PretrainedOptions">PretrainedOptions</a></code></td><td><p>An object containing optional parameters.</p></td> </tr><tr><td>[cache]</td><td><code><a href="#CacheInterface">CacheInterface</a></code> | <code>null</code></td><td><p>The cache instance to use for determining cache keys.</p></td></tr></tbody></table> <hr> <a id="module_utils/hub.checkCachedResource" class="group"></a> <h2 class="relative group"><a id="utilshubcheckcachedresourcecache-localpath-proposedcachekey--promise--responsefileresponseundefinedstring-" 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="#utilshubcheckcachedresourcecache-localpath-proposedcachekey--promise--responsefileresponseundefinedstring-"><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/hub.checkCachedResource(cache, localPath, proposedCacheKey) ⇒ Promise. &lt; (Response|FileResponse|undefined|string) ></span></h2> <p data-svelte-h="svelte-ukv10i">Checks if a resource exists in cache.</p> <p data-svelte-h="svelte-nzzg4j"><strong>Kind</strong>: static method of <a href="#module_utils/hub"><code>utils/hub</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;(Response|FileResponse|undefined|string)&gt;</code> - The cached response if found, undefined otherwise.</p> <table data-svelte-h="svelte-1pnkwog"><thead><tr><th>Param</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr><td>cache</td><td><code><a href="#CacheInterface">CacheInterface</a></code> | <code>null</code></td><td><p>The cache instance to check.</p></td> </tr><tr><td>localPath</td><td><code>string</code></td><td><p>The local path to try first.</p></td> </tr><tr><td>proposedCacheKey</td><td><code>string</code></td><td><p>The proposed cache key to try second.</p></td></tr></tbody></table> <hr> <a id="module_utils/hub.storeCachedResource" class="group"></a> <h2 class="relative group"><a id="utilshubstorecachedresourcepathorrepoid-filename-cache-cachekey-response-result-options--promise--void-" 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="#utilshubstorecachedresourcepathorrepoid-filename-cache-cachekey-response-result-options--promise--void-"><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/hub.storeCachedResource(path_or_repo_id, filename, cache, cacheKey, response, [result], [options]) ⇒ Promise. &lt; void ></span></h2> <p data-svelte-h="svelte-1q75n6n">Stores a resource in the cache.</p> <p data-svelte-h="svelte-1q3me2x"><strong>Kind</strong>: static method of <a href="#module_utils/hub"><code>utils/hub</code></a></p> <table data-svelte-h="svelte-63mm1z"><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>The path or repo ID of the model.</p></td> </tr><tr><td>filename</td><td><code>string</code></td><td><p>The name of the file to cache.</p></td> </tr><tr><td>cache</td><td><code><a href="#CacheInterface">CacheInterface</a></code></td><td><p>The cache instance to store in.</p></td> </tr><tr><td>cacheKey</td><td><code>string</code></td><td><p>The cache key to use.</p></td> </tr><tr><td>response</td><td><code>Response</code> | <code>FileResponse</code></td><td><p>The response to cache.</p></td> </tr><tr><td>[result]</td><td><code>Uint8Array</code></td><td><p>The result buffer if already read.</p></td> </tr><tr><td>[options]</td><td><code><a href="#PretrainedOptions">PretrainedOptions</a></code></td><td><p>Options containing progress callback and context for progress updates.</p></td></tr></tbody></table> <hr> <a id="module_utils/hub.loadResourceFile" class="group"></a> <h2 class="relative group"><a id="utilshubloadresourcefilepathorrepoid-filename-fatal-options-returnpath-cache--promise--stringuint8arraynull-" 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="#utilshubloadresourcefilepathorrepoid-filename-fatal-options-returnpath-cache--promise--stringuint8arraynull-"><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/hub.loadResourceFile(path_or_repo_id, filename, [fatal], [options], [return_path], [cache]) ⇒ Promise. &lt; (string|Uint8Array|null) ></span></h2> <p data-svelte-h="svelte-zecumy">Loads a resource file from local or remote sources.</p> <p data-svelte-h="svelte-14k8uss"><strong>Kind</strong>: static method of <a href="#module_utils/hub"><code>utils/hub</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;(string|Uint8Array|null)&gt;</code> - A Promise that resolves with the file content as a Uint8Array if <code>return_path</code> is false, or the file path as a string if <code>return_path</code> is true.<br> <strong>Throws</strong>:</p> <ul data-svelte-h="svelte-jl6z4b"><li>Will throw an error if the file is not found and <code>fatal</code> is true.</li></ul> <table data-svelte-h="svelte-1yegmq"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>path_or_repo_id</td><td><code>string</code></td><td></td><td><p>This can be either:</p> <ul><li>a string, the <em>model id</em> of a model repo on huggingface.co.</li> <li>a path to a <em>directory</em> potentially containing the file.</li></ul></td> </tr><tr><td>filename</td><td><code>string</code></td><td></td><td><p>The name of the file to locate.</p></td> </tr><tr><td>[fatal]</td><td><code>boolean</code></td><td><code>true</code></td><td><p>Whether to throw an error if the file is not found.</p></td> </tr><tr><td>[options]</td><td><code><a href="#PretrainedOptions">PretrainedOptions</a></code></td><td></td><td><p>An object containing optional parameters.</p></td> </tr><tr><td>[return_path]</td><td><code>boolean</code></td><td><code>false</code></td><td><p>Whether to return the path of the file instead of the file content.</p></td> </tr><tr><td>[cache]</td><td><code><a href="#CacheInterface">CacheInterface</a></code> | <code>null</code></td><td></td><td><p>The cache instance to use.</p></td></tr></tbody></table> <ul data-svelte-h="svelte-1dtp7aw"><li><a href="#module_utils/hub.loadResourceFile"><code>.loadResourceFile(path_or_repo_id, filename, [fatal], [options], [return_path], [cache])</code></a><code>Promise.&lt;(string|Uint8Array|null)&gt;</code> <ul><li><a href="#module_utils/hub.loadResourceFile..cacheKey"><code>~cacheKey</code></a> : <code>string</code></li> <li><a href="#module_utils/hub.loadResourceFile..response"><code>~response</code></a> : <code>Response</code> | <code>FileResponse</code> | <code>undefined</code> | <code>string</code></li> <li><a href="#module_utils/hub.loadResourceFile..buffer"><code>~buffer</code></a> : <code>Uint8Array</code></li></ul></li></ul> <hr> <a id="module_utils/hub.loadResourceFile..cacheKey" class="group"></a> <h3 class="relative group"><a id="loadresourcefilecachekey--string" 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="#loadresourcefilecachekey--string"><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>loadResourceFile~cacheKey : string</span></h3> <p data-svelte-h="svelte-1dr6grc"><strong>Kind</strong>: inner property of <a href="#module_utils/hub.loadResourceFile"><code>loadResourceFile</code></a></p> <hr> <a id="module_utils/hub.loadResourceFile..response" class="group"></a> <h3 class="relative group"><a id="loadresourcefileresponse--response--fileresponse--undefined--string" 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="#loadresourcefileresponse--response--fileresponse--undefined--string"><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>loadResourceFile~response : Response | FileResponse | undefined | string</span></h3> <p data-svelte-h="svelte-1dr6grc"><strong>Kind</strong>: inner property of <a href="#module_utils/hub.loadResourceFile"><code>loadResourceFile</code></a></p> <hr> <a id="module_utils/hub.loadResourceFile..buffer" class="group"></a> <h3 class="relative group"><a id="loadresourcefilebuffer--uint8array" 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="#loadresourcefilebuffer--uint8array"><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>loadResourceFile~buffer : Uint8Array</span></h3> <p data-svelte-h="svelte-1dr6grc"><strong>Kind</strong>: inner property of <a href="#module_utils/hub.loadResourceFile"><code>loadResourceFile</code></a></p> <hr> <a id="module_utils/hub.getModelFile" class="group"></a> <h2 class="relative group"><a id="utilshubgetmodelfilepathorrepoid-filename-fatal-options-returnpath--promise--stringuint8array-" 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="#utilshubgetmodelfilepathorrepoid-filename-fatal-options-returnpath--promise--stringuint8array-"><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/hub.getModelFile(path_or_repo_id, filename, [fatal], [options], [return_path]) ⇒ Promise. &lt; (string|Uint8Array) ></span></h2> <p data-svelte-h="svelte-1l3bjq3">Retrieves a file from either a remote URL using the Fetch API or from the local file system using the FileSystem API.
If the filesystem is available and <code>env.useCache = true</code>, the file will be downloaded and cached.</p> <p data-svelte-h="svelte-1j9rqit"><strong>Kind</strong>: static method of <a href="#module_utils/hub"><code>utils/hub</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;(string|Uint8Array)&gt;</code> - A Promise that resolves with the file content as a Uint8Array if <code>return_path</code> is false, or the file path as a string if <code>return_path</code> is true.<br> <strong>Throws</strong>:</p> <ul data-svelte-h="svelte-jl6z4b"><li>Will throw an error if the file is not found and <code>fatal</code> is true.</li></ul> <table data-svelte-h="svelte-hk6v21"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>path_or_repo_id</td><td><code>string</code></td><td></td><td><p>This can be either:</p> <ul><li>a string, the <em>model id</em> of a model repo on huggingface.co.</li> <li>a path to a <em>directory</em> potentially containing the file.</li></ul></td> </tr><tr><td>filename</td><td><code>string</code></td><td></td><td><p>The name of the file to locate in <code>path_or_repo</code>.</p></td> </tr><tr><td>[fatal]</td><td><code>boolean</code></td><td><code>true</code></td><td><p>Whether to throw an error if the file is not found.</p></td> </tr><tr><td>[options]</td><td><code><a href="#PretrainedOptions">PretrainedOptions</a></code></td><td></td><td><p>An object containing optional parameters.</p></td> </tr><tr><td>[return_path]</td><td><code>boolean</code></td><td><code>false</code></td><td><p>Whether to return the path of the file instead of the file content.</p></td></tr></tbody></table> <hr> <a id="module_utils/hub.getModelFile..cache" class="group"></a> <h3 class="relative group"><a id="getmodelfilecache--cacheinterface--null" 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="#getmodelfilecache--cacheinterface--null"><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>getModelFile~cache : CacheInterface | null</span></h3> <p data-svelte-h="svelte-1eej6dp"><strong>Kind</strong>: inner constant of <a href="#module_utils/hub.getModelFile"><code>getModelFile</code></a></p> <hr> <a id="module_utils/hub.getModelText" class="group"></a> <h2 class="relative group"><a id="utilshubgetmodeltextmodelpath-filename-fatal-options--promise--stringnull-" 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="#utilshubgetmodeltextmodelpath-filename-fatal-options--promise--stringnull-"><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/hub.getModelText(modelPath, fileName, [fatal], [options]) ⇒ Promise. &lt; (string|null) ></span></h2> <p data-svelte-h="svelte-csw6h7">Fetches a text file from a given path and file name.</p> <p data-svelte-h="svelte-130mlcm"><strong>Kind</strong>: static method of <a href="#module_utils/hub"><code>utils/hub</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;(string|null)&gt;</code> - The text content of the file.<br> <strong>Throws</strong>:</p> <ul data-svelte-h="svelte-jl6z4b"><li>Will throw an error if the file is not found and <code>fatal</code> is true.</li></ul> <table data-svelte-h="svelte-iawspw"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>modelPath</td><td><code>string</code></td><td></td><td><p>The path to the directory containing the file.</p></td> </tr><tr><td>fileName</td><td><code>string</code></td><td></td><td><p>The name of the file to fetch.</p></td> </tr><tr><td>[fatal]</td><td><code>boolean</code></td><td><code>true</code></td><td><p>Whether to throw an error if the file is not found.</p></td> </tr><tr><td>[options]</td><td><code><a href="#PretrainedOptions">PretrainedOptions</a></code></td><td></td><td><p>An object containing optional parameters.</p></td></tr></tbody></table> <hr> <a id="module_utils/hub.getModelJSON" class="group"></a> <h2 class="relative group"><a id="utilshubgetmodeljsonmodelpath-filename-fatal-options--promise--object-" 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="#utilshubgetmodeljsonmodelpath-filename-fatal-options--promise--object-"><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/hub.getModelJSON(modelPath, fileName, [fatal], [options]) ⇒ Promise. &lt; Object ></span></h2> <p data-svelte-h="svelte-1en2wh4">Fetches a JSON file from a given path and file name.</p> <p data-svelte-h="svelte-1l5qo0i"><strong>Kind</strong>: static method of <a href="#module_utils/hub"><code>utils/hub</code></a><br> <strong>Returns</strong>: <code>Promise.&lt;Object&gt;</code> - The JSON data parsed into a JavaScript object.<br> <strong>Throws</strong>:</p> <ul data-svelte-h="svelte-jl6z4b"><li>Will throw an error if the file is not found and <code>fatal</code> is true.</li></ul> <table data-svelte-h="svelte-iawspw"><thead><tr><th>Param</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>modelPath</td><td><code>string</code></td><td></td><td><p>The path to the directory containing the file.</p></td> </tr><tr><td>fileName</td><td><code>string</code></td><td></td><td><p>The name of the file to fetch.</p></td> </tr><tr><td>[fatal]</td><td><code>boolean</code></td><td><code>true</code></td><td><p>Whether to throw an error if the file is not found.</p></td> </tr><tr><td>[options]</td><td><code><a href="#PretrainedOptions">PretrainedOptions</a></code></td><td></td><td><p>An object containing optional parameters.</p></td></tr></tbody></table> <hr> <a id="module_utils/hub..INFLIGHT_LOADS" class="group"></a> <h2 class="relative group"><a id="utilshubinflightloads--map--string-promise--stringuint8array--" 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="#utilshubinflightloads--map--string-promise--stringuint8array--"><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/hub~INFLIGHT_LOADS : Map. &lt; string, Promise. &lt; (string|Uint8Array) > ></span></h2> <p data-svelte-h="svelte-irr1v0">In-flight file loads keyed by repo+filename.</p> <p data-svelte-h="svelte-1tftvai"><strong>Kind</strong>: inner constant of <a href="#module_utils/hub"><code>utils/hub</code></a></p> <hr> <a id="module_utils/hub..ExternalData" class="group"></a> <h2 class="relative group"><a id="utilshubexternaldata--boolean--number" 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="#utilshubexternaldata--boolean--number"><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/hub~ExternalData : boolean | number</span></h2> <p data-svelte-h="svelte-1swr7m">Specifies whether to load the model using the external data format.</p> <ul data-svelte-h="svelte-1x1hwlk"><li><code>false</code>: Do not use external data format</li> <li><code>true</code>: Use external data format with 1 chunk</li> <li><code>number</code>: Use external data format with the specified number of chunks</li></ul> <p data-svelte-h="svelte-ghvp2p"><strong>Kind</strong>: inner typedef of <a href="#module_utils/hub"><code>utils/hub</code></a></p> <hr> <a id="module_utils/hub..PretrainedOptions" class="group"></a> <h2 class="relative group"><a id="utilshubpretrainedoptions--object" 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="#utilshubpretrainedoptions--object"><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/hub~PretrainedOptions : Object</span></h2> <p data-svelte-h="svelte-1oi15lr">Options for loading a pretrained model.</p> <p data-svelte-h="svelte-121rdz"><strong>Kind</strong>: inner typedef of <a href="#module_utils/hub"><code>utils/hub</code></a><br> <strong>Properties</strong></p> <table data-svelte-h="svelte-1x33l8x"><thead><tr><th>Name</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>[progress_callback]</td><td><code>ProgressCallback</code></td><td><code></code></td><td><p>If specified, this function will be called during model construction, to provide the user with progress updates.</p></td> </tr><tr><td>[config]</td><td><code><a href="#PretrainedConfig">PretrainedConfig</a></code></td><td><code></code></td><td><p>Configuration for the model to use instead of an automatically loaded configuration. Configuration can be automatically loaded when:</p> <ul><li>The model is a model provided by the library (loaded with the <em>model id</em> string of a pretrained model).</li> <li>The model is loaded by supplying a local directory as <code>pretrained_model_name_or_path</code> and a configuration JSON file named <em>config.json</em> is found in the directory.</li></ul></td> </tr><tr><td>[cache_dir]</td><td><code>string</code></td><td><code>null</code></td><td><p>Path to a directory in which a downloaded pretrained model configuration should be cached if the standard cache should not be used.</p></td> </tr><tr><td>[local_files_only]</td><td><code>boolean</code></td><td><code>false</code></td><td><p>Whether or not to only look at local files (e.g., not try downloading the model).</p></td> </tr><tr><td>[revision]</td><td><code>string</code></td><td><code>&quot;&#39;main&#39;&quot;</code></td><td><p>The specific model version to use. It can be a branch name, a tag name, or a commit id,
since we use a git-based system for storing models and other artifacts on huggingface.co, so <code>revision</code> can be any identifier allowed by git.
NOTE: This setting is ignored for local requests.</p></td></tr></tbody></table> <hr> <a id="module_utils/hub..ModelSpecificPretrainedOptions" class="group"></a> <h2 class="relative group"><a id="utilshubmodelspecificpretrainedoptions--object" 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="#utilshubmodelspecificpretrainedoptions--object"><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/hub~ModelSpecificPretrainedOptions : Object</span></h2> <p data-svelte-h="svelte-1oi15lr">Options for loading a pretrained model.</p> <p data-svelte-h="svelte-121rdz"><strong>Kind</strong>: inner typedef of <a href="#module_utils/hub"><code>utils/hub</code></a><br> <strong>Properties</strong></p> <table data-svelte-h="svelte-19xdsoi"><thead><tr><th>Name</th><th>Type</th><th>Default</th><th>Description</th></tr></thead> <tbody><tr><td>[subfolder]</td><td><code>string</code></td><td><code>&quot;&#39;onnx&#39;&quot;</code></td><td><p>In case the relevant files are located inside a subfolder of the model repo on huggingface.co,
you can specify the folder name here.</p></td> </tr><tr><td>[model_file_name]</td><td><code>string</code></td><td><code>null</code></td><td><p>If specified, load the model with this name (excluding the dtype and .onnx suffixes). Currently only valid for encoder- or decoder-only models.</p></td> </tr><tr><td>[device]</td><td><code><a href="#DeviceType">DeviceType</a></code> | <code>Record.&lt;string, DeviceType&gt;</code></td><td><code></code></td><td><p>The device to run the model on. If not specified, the device will be chosen from the environment settings.</p></td> </tr><tr><td>[dtype]</td><td><code><a href="#DataType">DataType</a></code> | <code>Record.&lt;string, DataType&gt;</code></td><td><code></code></td><td><p>The data type to use for the model. If not specified, the data type will be chosen from the environment settings.</p></td> </tr><tr><td>[use_external_data_format]</td><td><code>ExternalData</code> | <code>Record.&lt;string, ExternalData&gt;</code></td><td><code>false</code></td><td><p>Whether to load the model using the external data format (used for models &gt;= 2GB in size).</p></td> </tr><tr><td>[session_options]</td><td><code>InferenceSession.SessionOptions</code></td><td></td><td><p>(Optional) User-specified session options passed to the runtime. If not provided, suitable defaults will be chosen.</p></td></tr></tbody></table> <hr> <a id="module_utils/hub..PretrainedModelOptions" class="group"></a> <h2 class="relative group"><a id="utilshubpretrainedmodeloptions--pretrainedoptions--modelspecificpretrainedoptions" 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="#utilshubpretrainedmodeloptions--pretrainedoptions--modelspecificpretrainedoptions"><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/hub~PretrainedModelOptions : PretrainedOptions | ModelSpecificPretrainedOptions</span></h2> <p data-svelte-h="svelte-1oi15lr">Options for loading a pretrained model.</p> <p data-svelte-h="svelte-ghvp2p"><strong>Kind</strong>: inner typedef of <a href="#module_utils/hub"><code>utils/hub</code></a></p> <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/hub.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, 18],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
58.3 kB
·
Xet hash:
d82590a71d5b5be31c49bc8181455f331cda632e31ac00a93d2cfb928da434e0

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