@huggingface/transformers 4.0.0-next.5 → 4.0.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -4
- package/dist/ort-wasm-simd-threaded.jsep.mjs +23 -23
- package/dist/transformers.js +575 -418
- package/dist/transformers.min.js +17 -17
- package/dist/transformers.node.cjs +672 -499
- package/dist/transformers.node.min.cjs +18 -18
- package/dist/transformers.node.min.mjs +18 -18
- package/dist/transformers.node.mjs +651 -491
- package/dist/transformers.web.js +559 -402
- package/dist/transformers.web.min.js +18 -18
- package/package.json +3 -3
- package/src/backends/onnx.js +77 -58
- package/src/backends/utils/cacheWasm.js +22 -43
- package/src/configs.js +17 -5
- package/src/env.js +29 -6
- package/src/models/auto/modeling_auto.js +14 -1
- package/src/models/modeling_utils.js +35 -7
- package/src/models/models.js +5 -0
- package/src/models/olmo_hybrid/modeling_olmo_hybrid.js +5 -0
- package/src/models/qwen2_moe/modeling_qwen2_moe.js +5 -0
- package/src/models/qwen2_vl/modeling_qwen2_vl.js +37 -4
- package/src/models/qwen3_moe/modeling_qwen3_moe.js +5 -0
- package/src/models/qwen3_next/modeling_qwen3_next.js +5 -0
- package/src/models/qwen3_vl_moe/modeling_qwen3_vl_moe.js +3 -0
- package/src/models/registry.js +14 -4
- package/src/pipelines/index.js +2 -84
- package/src/pipelines.js +40 -77
- package/src/utils/cache/FileCache.js +128 -0
- package/src/utils/cache.js +3 -3
- package/src/utils/hub/{files.js → FileResponse.js} +0 -105
- package/src/utils/hub/utils.js +35 -1
- package/src/utils/hub.js +6 -5
- package/src/utils/image.js +12 -13
- package/src/utils/model_registry/ModelRegistry.js +70 -23
- package/src/utils/model_registry/get_model_files.js +12 -1
- package/src/utils/model_registry/get_pipeline_files.js +15 -24
- package/src/utils/model_registry/is_cached.js +81 -4
- package/types/backends/onnx.d.ts.map +1 -1
- package/types/backends/utils/cacheWasm.d.ts +3 -17
- package/types/backends/utils/cacheWasm.d.ts.map +1 -1
- package/types/configs.d.ts.map +1 -1
- package/types/env.d.ts +10 -3
- package/types/env.d.ts.map +1 -1
- package/types/models/auto/modeling_auto.d.ts +6 -0
- package/types/models/auto/modeling_auto.d.ts.map +1 -1
- package/types/models/modeling_utils.d.ts +13 -2
- package/types/models/modeling_utils.d.ts.map +1 -1
- package/types/models/models.d.ts +5 -0
- package/types/models/olmo_hybrid/modeling_olmo_hybrid.d.ts +8 -0
- package/types/models/olmo_hybrid/modeling_olmo_hybrid.d.ts.map +1 -0
- package/types/models/qwen2_moe/modeling_qwen2_moe.d.ts +8 -0
- package/types/models/qwen2_moe/modeling_qwen2_moe.d.ts.map +1 -0
- package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts.map +1 -1
- package/types/models/qwen3_moe/modeling_qwen3_moe.d.ts +8 -0
- package/types/models/qwen3_moe/modeling_qwen3_moe.d.ts.map +1 -0
- package/types/models/qwen3_next/modeling_qwen3_next.d.ts +8 -0
- package/types/models/qwen3_next/modeling_qwen3_next.d.ts.map +1 -0
- package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts +4 -0
- package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts.map +1 -0
- package/types/models/registry.d.ts +2 -1
- package/types/models/registry.d.ts.map +1 -1
- package/types/pipelines/index.d.ts +0 -34
- package/types/pipelines/index.d.ts.map +1 -1
- package/types/pipelines.d.ts.map +1 -1
- package/types/utils/cache/FileCache.d.ts +39 -0
- package/types/utils/cache/FileCache.d.ts.map +1 -0
- package/types/utils/cache.d.ts +4 -4
- package/types/utils/cache.d.ts.map +1 -1
- package/types/utils/hub/{files.d.ts → FileResponse.d.ts} +1 -38
- package/types/utils/hub/FileResponse.d.ts.map +1 -0
- package/types/utils/hub/utils.d.ts +17 -2
- package/types/utils/hub/utils.d.ts.map +1 -1
- package/types/utils/hub.d.ts +7 -7
- package/types/utils/hub.d.ts.map +1 -1
- package/types/utils/image.d.ts.map +1 -1
- package/types/utils/model_registry/ModelRegistry.d.ts +66 -6
- package/types/utils/model_registry/ModelRegistry.d.ts.map +1 -1
- package/types/utils/model_registry/get_model_files.d.ts.map +1 -1
- package/types/utils/model_registry/get_pipeline_files.d.ts +2 -1
- package/types/utils/model_registry/get_pipeline_files.d.ts.map +1 -1
- package/types/utils/model_registry/is_cached.d.ts +47 -4
- package/types/utils/model_registry/is_cached.d.ts.map +1 -1
- package/types/utils/hub/files.d.ts.map +0 -1
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Quickly checks if a model is cached by verifying that `config.json` is present,
|
|
3
|
+
* then confirming all required files are cached.
|
|
4
|
+
* Returns a plain boolean — use `is_cached_files` if you need per-file detail.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} modelId The model id (e.g., "Xenova/gpt2")
|
|
7
|
+
* @param {Object} [options] Optional parameters
|
|
8
|
+
* @param {string} [options.cache_dir] Custom cache directory
|
|
9
|
+
* @param {string} [options.revision] Model revision (default: 'main')
|
|
10
|
+
* @param {import('../../configs.js').PretrainedConfig} [options.config] Pre-loaded config
|
|
11
|
+
* @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype] Override dtype
|
|
12
|
+
* @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] Override device
|
|
13
|
+
* @returns {Promise<boolean>} Whether all required files are cached
|
|
14
|
+
*/
|
|
15
|
+
export function is_cached(modelId: string, options?: {
|
|
16
|
+
cache_dir?: string;
|
|
17
|
+
revision?: string;
|
|
18
|
+
config?: import("../../configs.js").PretrainedConfig;
|
|
19
|
+
dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
|
|
20
|
+
device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
|
|
21
|
+
}): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if all files for a given model are already cached, with per-file detail.
|
|
3
24
|
* Automatically determines which files are needed using get_files().
|
|
4
25
|
*
|
|
5
26
|
* @param {string} modelId The model id (e.g., "Xenova/gpt2")
|
|
@@ -11,7 +32,7 @@
|
|
|
11
32
|
* @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] Override device
|
|
12
33
|
* @returns {Promise<CacheCheckResult>} Object with allCached boolean and files array with cache status
|
|
13
34
|
*/
|
|
14
|
-
export function
|
|
35
|
+
export function is_cached_files(modelId: string, options?: {
|
|
15
36
|
cache_dir?: string;
|
|
16
37
|
revision?: string;
|
|
17
38
|
config?: import("../../configs.js").PretrainedConfig;
|
|
@@ -19,7 +40,29 @@ export function is_cached(modelId: string, options?: {
|
|
|
19
40
|
device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
|
|
20
41
|
}): Promise<CacheCheckResult>;
|
|
21
42
|
/**
|
|
22
|
-
*
|
|
43
|
+
* Quickly checks if all files for a specific pipeline task are cached by verifying
|
|
44
|
+
* that `config.json` is present, then confirming all required files are cached.
|
|
45
|
+
* Returns a plain boolean — use `is_pipeline_cached_files` if you need per-file detail.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} task - The pipeline task (e.g., "text-generation", "image-classification")
|
|
48
|
+
* @param {string} modelId - The model id (e.g., "Xenova/gpt2")
|
|
49
|
+
* @param {Object} [options] - Optional parameters
|
|
50
|
+
* @param {string} [options.cache_dir] - Custom cache directory
|
|
51
|
+
* @param {string} [options.revision] - Model revision (default: 'main')
|
|
52
|
+
* @param {import('../../configs.js').PretrainedConfig} [options.config] - Pre-loaded config
|
|
53
|
+
* @param {import('../dtypes.js').DataType|Record<string, import('../dtypes.js').DataType>} [options.dtype] - Override dtype
|
|
54
|
+
* @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] - Override device
|
|
55
|
+
* @returns {Promise<boolean>} Whether all required files are cached
|
|
56
|
+
*/
|
|
57
|
+
export function is_pipeline_cached(task: string, modelId: string, options?: {
|
|
58
|
+
cache_dir?: string;
|
|
59
|
+
revision?: string;
|
|
60
|
+
config?: import("../../configs.js").PretrainedConfig;
|
|
61
|
+
dtype?: import("../dtypes.js").DataType | Record<string, import("../dtypes.js").DataType>;
|
|
62
|
+
device?: import("../devices.js").DeviceType | Record<string, import("../devices.js").DeviceType>;
|
|
63
|
+
}): Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Checks if all files for a specific pipeline task are already cached, with per-file detail.
|
|
23
66
|
* Automatically determines which components are needed based on the task.
|
|
24
67
|
*
|
|
25
68
|
* @param {string} task - The pipeline task (e.g., "text-generation", "image-classification")
|
|
@@ -32,7 +75,7 @@ export function is_cached(modelId: string, options?: {
|
|
|
32
75
|
* @param {import('../devices.js').DeviceType|Record<string, import('../devices.js').DeviceType>} [options.device] - Override device
|
|
33
76
|
* @returns {Promise<CacheCheckResult>} Object with allCached boolean and files array with cache status
|
|
34
77
|
*/
|
|
35
|
-
export function
|
|
78
|
+
export function is_pipeline_cached_files(task: string, modelId: string, options?: {
|
|
36
79
|
cache_dir?: string;
|
|
37
80
|
revision?: string;
|
|
38
81
|
config?: import("../../configs.js").PretrainedConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is_cached.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/is_cached.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is_cached.d.ts","sourceRoot":"","sources":["../../../src/utils/model_registry/is_cached.js"],"names":[],"mappings":"AA4DA;;;;;;;;;;;;;GAaG;AACH,mCATW,MAAM,YAEd;IAAyB,SAAS,GAA1B,MAAM;IACW,QAAQ,GAAzB,MAAM;IACgD,MAAM,GAA5D,OAAO,kBAAkB,EAAE,gBAAgB;IAC+C,KAAK,GAA/F,OAAO,cAAc,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,EAAE,QAAQ,CAAC;IACiB,MAAM,GAAtG,OAAO,eAAe,EAAE,UAAU,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO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