Buckets:
env
Global configuration for the library. Mutate fields on the exported
env object at startup to change where models are loaded from, how files
are cached, and how verbose logging is.
Example: Load models from your own server and disable remote downloads.
import { env } from '@huggingface/transformers';
env.allowRemoteModels = false;
env.localModelPath = '/path/to/local/models/';
Example: Point the filesystem cache at a custom directory (Node.js).
import { env } from '@huggingface/transformers';
env.cacheDir = '/path/to/cache/directory/';
Constants
LogLevel
Log-level enum. Assign to env.logLevel to control how verbose the library
is. Higher values silence more: DEBUG (10) surfaces everything,
NONE (50) suppresses all output. Default is WARNING (30).
| Level | Value | Shows |
|---|---|---|
DEBUG |
10 | Every message, including debug traces. |
INFO |
20 | Errors, warnings, and info messages. |
WARNING |
30 | Errors and warnings. |
ERROR |
40 | Only errors. |
NONE |
50 | Nothing. |
import { env, LogLevel } from '@huggingface/transformers';
env.logLevel = LogLevel.ERROR;
env : TransformersEnvironment
The global configuration object. See TransformersEnvironment below for the
full set of fields.
Type Definitions
TransformersEnvironment
Shape of the env object. Every field is mutable.
Properties
version(string) — This version of Transformers.js.backends(object) — Exposes backend environment settings that users can override.logLevel(number) — The logging level. Use LogLevel enum values. Defaults to LogLevel.WARNING.allowRemoteModels(boolean) — Whether to allow loading of remote files, defaults totrue. If set tofalse, it will have the same effect as settinglocal_files_only=truewhen loading pipelines, models, tokenizers, processors, etc.remoteHost(string) — Host URL to load models from. Defaults to the Hugging Face Hub.remotePathTemplate(string) — Path template to fill in and append toremoteHostwhen loading models.allowLocalModels(boolean) — Whether to allow loading of local files, defaults tofalseif running in-browser, andtrueotherwise. If set tofalse, it will skip the local file check and try to load the model from the remote host.localModelPath(string) — Path to load local models from. Defaults to/models/.useFS(boolean) — Whether to use the file system to load files. By default, it istrueif available.useBrowserCache(boolean) — Whether to use Cache API to cache models. By default, it istrueif available.useFSCache(boolean) — Whether to use the file system to cache files. By default, it istrueif available.cacheDir(string|null) — The directory to use for caching files with the file system. By default, it is./.cache.useCustomCache(boolean) — Whether to use a custom cache system (defined bycustomCache), defaults tofalse.customCache(CacheInterface|null) — The custom cache to use. Defaults tonull. This must be an object that implements thematchandputfunctions of the Web Cache API. For more information, see https://developer.mozilla.org/en-US/docs/Web/API/Cache.useWasmCache(boolean) — Whether to pre-load and cache WASM binaries and the WASM factory (.mjs) for ONNX Runtime. Defaults totruewhen cache is available. This can improve performance and enables offline usage by avoiding repeated downloads.cacheKey(string) — The cache key to use for storing models and WASM binaries. Defaults totransformers-cache.experimental_useCrossOriginStorage(boolean) — 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 tofalse. Requires the Cross-Origin Storage Chrome extension: https://chromewebstore.google.com/detail/cross-origin-storage/denpnpcgjgikjpoglpjefakmdcbmlgih. Theexperimental_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 https://github.com/WICG/cross-origin-storage.fetch(object) — The fetch function to use. Defaults tofetch.
Xet Storage Details
- Size:
- 4.81 kB
- Xet hash:
- cf369a8dbebc6b2811214c2468bbb77f586f53989823f84662c82cbfa118104a
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.