Buckets:

download
raw
23.4 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;env&quot;,&quot;local&quot;:&quot;env&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Constants&quot;,&quot;local&quot;:&quot;constants&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;LogLevel&quot;,&quot;local&quot;:&quot;loglevel&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;env : TransformersEnvironment&quot;,&quot;local&quot;:&quot;env--transformersenvironment&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Type Definitions&quot;,&quot;local&quot;:&quot;type-definitions&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;TransformersEnvironment&quot;,&quot;local&quot;:&quot;transformersenvironment&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2}],&quot;depth&quot;:1}">
<link href="/docs/transformers.js/pr_1665/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/entry/start.cb58eb6f.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/scheduler.6efaaf90.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/singletons.08239980.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/paths.611c3944.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/entry/app.9eafcf9d.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/preload-helper.4b821645.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/index.eb3e1f0f.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/nodes/0.d361a553.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/each.e59479a4.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/nodes/4.a89dd1fc.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.699f2734.js">
<link rel="modulepreload" href="/docs/transformers.js/pr_1665/en/_app/immutable/chunks/CodeBlock.b303f0b9.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;env&quot;,&quot;local&quot;:&quot;env&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Constants&quot;,&quot;local&quot;:&quot;constants&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;LogLevel&quot;,&quot;local&quot;:&quot;loglevel&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;env : TransformersEnvironment&quot;,&quot;local&quot;:&quot;env--transformersenvironment&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Type Definitions&quot;,&quot;local&quot;:&quot;type-definitions&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;TransformersEnvironment&quot;,&quot;local&quot;:&quot;transformersenvironment&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="env" 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="#env"><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>env</span></h1> <p data-svelte-h="svelte-1byz145">Global configuration for the library. Mutate fields on the exported
<code>env</code> object at startup to change where models are loaded from, how files
are cached, and how verbose logging is.</p> <p data-svelte-h="svelte-swc4xz"><strong>Example:</strong> Load models from your own server and disable remote downloads.</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="language-javascript "><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> { env } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@huggingface/transformers&#x27;</span>;
env.<span class="hljs-property">allowRemoteModels</span> = <span class="hljs-literal">false</span>;
env.<span class="hljs-property">localModelPath</span> = <span class="hljs-string">&#x27;/path/to/local/models/&#x27;</span>;<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-pwmkz"><strong>Example:</strong> Point the filesystem cache at a custom directory (Node.js).</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="language-javascript "><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> { env } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@huggingface/transformers&#x27;</span>;
env.<span class="hljs-property">cacheDir</span> = <span class="hljs-string">&#x27;/path/to/cache/directory/&#x27;</span>;<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="constants" 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="#constants"><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>Constants</span></h2> <a id="module_env.LogLevel"></a> <h3 class="relative group"><a id="loglevel" 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="#loglevel"><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>LogLevel</span></h3> <p data-svelte-h="svelte-b670vy">Log-level enum. Assign to <code>env.logLevel</code> to control how verbose the library
is. Higher values silence more: <code>DEBUG</code> (10) surfaces everything,
<code>NONE</code> (50) suppresses all output. Default is <code>WARNING</code> (30).</p> <table data-svelte-h="svelte-4uoaqu"><thead><tr><th>Level</th> <th>Value</th> <th>Shows</th></tr></thead> <tbody><tr><td><code>DEBUG</code></td> <td>10</td> <td>Every message, including debug traces.</td></tr> <tr><td><code>INFO</code></td> <td>20</td> <td>Errors, warnings, and info messages.</td></tr> <tr><td><code>WARNING</code></td> <td>30</td> <td>Errors and warnings.</td></tr> <tr><td><code>ERROR</code></td> <td>40</td> <td>Only errors.</td></tr> <tr><td><code>NONE</code></td> <td>50</td> <td>Nothing.</td></tr></tbody></table> <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="language-javascript "><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> { env, <span class="hljs-title class_">LogLevel</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@huggingface/transformers&#x27;</span>;
env.<span class="hljs-property">logLevel</span> = <span class="hljs-title class_">LogLevel</span>.<span class="hljs-property">ERROR</span>;<!-- HTML_TAG_END --></pre></div> <a id="module_env.env"></a> <h3 class="relative group"><a id="env--transformersenvironment" 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="#env--transformersenvironment"><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>env : TransformersEnvironment</span></h3> <p data-svelte-h="svelte-15hzuz8">The global configuration object. See <code>TransformersEnvironment</code> below for the
full set of fields.</p> <h2 class="relative group"><a id="type-definitions" 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="#type-definitions"><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>Type Definitions</span></h2> <a id="module_env.TransformersEnvironment"></a> <h3 class="relative group"><a id="transformersenvironment" 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="#transformersenvironment"><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>TransformersEnvironment</span></h3> <p data-svelte-h="svelte-1ge56p">Shape of the <code>env</code> object. Every field is mutable.</p> <p data-svelte-h="svelte-drbxoe"><strong>Properties</strong></p> <ul data-svelte-h="svelte-dfp96z"><li><code>version</code> (<code>string</code>) — This version of Transformers.js.</li> <li><code>backends</code> (<code>object</code>) — Exposes backend environment settings that users can override.</li> <li><code>logLevel</code> (<code>number</code>) — The logging level. Use LogLevel enum values. Defaults to LogLevel.WARNING.</li> <li><code>allowRemoteModels</code> (<code>boolean</code>) — Whether to allow loading of remote files, defaults to <code>true</code>.
If set to <code>false</code>, it will have the same effect as setting <code>local_files_only=true</code> when loading pipelines, models, tokenizers, processors, etc.</li> <li><code>remoteHost</code> (<code>string</code>) — Host URL to load models from. Defaults to the Hugging Face Hub.</li> <li><code>remotePathTemplate</code> (<code>string</code>) — Path template to fill in and append to <code>remoteHost</code> when loading models.</li> <li><code>allowLocalModels</code> (<code>boolean</code>) — Whether to allow loading of local files, defaults to <code>false</code> if running in-browser, and <code>true</code> otherwise.
If set to <code>false</code>, it will skip the local file check and try to load the model from the remote host.</li> <li><code>localModelPath</code> (<code>string</code>) — Path to load local models from. Defaults to <code>/models/</code>.</li> <li><code>useFS</code> (<code>boolean</code>) — Whether to use the file system to load files. By default, it is <code>true</code> if available.</li> <li><code>useBrowserCache</code> (<code>boolean</code>) — Whether to use Cache API to cache models. By default, it is <code>true</code> if available.</li> <li><code>useFSCache</code> (<code>boolean</code>) — Whether to use the file system to cache files. By default, it is <code>true</code> if available.</li> <li><code>cacheDir</code> (<code>string</code> | <code>null</code>) — The directory to use for caching files with the file system. By default, it is <code>./.cache</code>.</li> <li><code>useCustomCache</code> (<code>boolean</code>) — Whether to use a custom cache system (defined by <code>customCache</code>), defaults to <code>false</code>.</li> <li><code>customCache</code> (<code>CacheInterface</code> | <code>null</code>) — The custom cache to use. Defaults to <code>null</code>. This must be an object that
implements the <code>match</code> and <code>put</code> functions of the Web Cache API. For more information, see <a href="https://developer.mozilla.org/en-US/docs/Web/API/Cache" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/API/Cache</a>.</li> <li><code>useWasmCache</code> (<code>boolean</code>) — Whether to pre-load and cache WASM binaries and the WASM factory (.mjs) for ONNX Runtime.
Defaults to <code>true</code> when cache is available. This can improve performance and enables offline usage by avoiding repeated downloads.</li> <li><code>cacheKey</code> (<code>string</code>) — The cache key to use for storing models and WASM binaries. Defaults to <code>transformers-cache</code>.</li> <li><code>experimental_useCrossOriginStorage</code> (<code>boolean</code>) — Whether to use the Cross-Origin Storage API to cache model files
across origins, allowing different sites to share the same cached model weights. Defaults to <code>false</code>.
Requires the Cross-Origin Storage Chrome extension: <a href="https://chromewebstore.google.com/detail/cross-origin-storage/denpnpcgjgikjpoglpjefakmdcbmlgih" rel="nofollow">https://chromewebstore.google.com/detail/cross-origin-storage/denpnpcgjgikjpoglpjefakmdcbmlgih</a>.
The <code>experimental_</code> prefix indicates that the underlying browser API is not yet standardized and may change or be
removed without a major version bump. For more information, see <a href="https://github.com/WICG/cross-origin-storage" rel="nofollow">https://github.com/WICG/cross-origin-storage</a>.</li> <li><code>fetch</code> (<code>object</code>) — The fetch function to use. Defaults to <code>fetch</code>.</li></ul> <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/env.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_1t06csc = {
assets: "/docs/transformers.js/pr_1665/en",
base: "/docs/transformers.js/pr_1665/en",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/transformers.js/pr_1665/en/_app/immutable/entry/start.cb58eb6f.js"),
import("/docs/transformers.js/pr_1665/en/_app/immutable/entry/app.9eafcf9d.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 4],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
23.4 kB
·
Xet hash:
1db8b7e2b0229c984b5f37bffdea84f21f8a9318e70a22b691d09a1305c85a20

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