@huggingface/transformers 3.1.1 → 3.1.2

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.
Files changed (119) hide show
  1. package/README.md +6 -3
  2. package/dist/ort-wasm-simd-threaded.jsep.wasm +0 -0
  3. package/dist/transformers.cjs +300 -55
  4. package/dist/transformers.cjs.map +1 -1
  5. package/dist/transformers.js +1468 -1105
  6. package/dist/transformers.js.map +1 -1
  7. package/dist/transformers.min.cjs +1 -358
  8. package/dist/transformers.min.cjs.map +1 -1
  9. package/dist/transformers.min.js +1 -421
  10. package/dist/transformers.min.js.map +1 -1
  11. package/dist/transformers.min.mjs +1 -358
  12. package/dist/transformers.min.mjs.map +1 -1
  13. package/dist/transformers.mjs +311 -54
  14. package/dist/transformers.mjs.map +1 -1
  15. package/package.json +11 -16
  16. package/src/backends/onnx.js +2 -7
  17. package/src/configs.js +1 -0
  18. package/src/env.js +1 -1
  19. package/src/models/paligemma/processing_paligemma.js +82 -0
  20. package/src/models/processors.js +1 -0
  21. package/src/models.js +57 -5
  22. package/src/tokenizers.js +12 -1
  23. package/src/utils/core.js +39 -9
  24. package/src/utils/hub.js +8 -12
  25. package/src/utils/image.js +40 -0
  26. package/types/backends/onnx.d.ts +2 -2
  27. package/types/backends/onnx.d.ts.map +1 -1
  28. package/types/base/feature_extraction_utils.d.ts +1 -1
  29. package/types/base/feature_extraction_utils.d.ts.map +1 -1
  30. package/types/base/image_processors_utils.d.ts +2 -2
  31. package/types/base/image_processors_utils.d.ts.map +1 -1
  32. package/types/base/processing_utils.d.ts +4 -4
  33. package/types/base/processing_utils.d.ts.map +1 -1
  34. package/types/configs.d.ts +7 -7
  35. package/types/configs.d.ts.map +1 -1
  36. package/types/env.d.ts +1 -1
  37. package/types/env.d.ts.map +1 -1
  38. package/types/generation/configuration_utils.d.ts +2 -2
  39. package/types/generation/logits_process.d.ts +2 -2
  40. package/types/generation/logits_process.d.ts.map +1 -1
  41. package/types/generation/logits_sampler.d.ts.map +1 -1
  42. package/types/generation/parameters.d.ts +5 -5
  43. package/types/generation/stopping_criteria.d.ts +1 -1
  44. package/types/generation/stopping_criteria.d.ts.map +1 -1
  45. package/types/generation/streamers.d.ts +2 -2
  46. package/types/generation/streamers.d.ts.map +1 -1
  47. package/types/models/audio_spectrogram_transformer/feature_extraction_audio_spectrogram_transformer.d.ts +1 -1
  48. package/types/models/audio_spectrogram_transformer/feature_extraction_audio_spectrogram_transformer.d.ts.map +1 -1
  49. package/types/models/auto/feature_extraction_auto.d.ts.map +1 -1
  50. package/types/models/auto/image_processing_auto.d.ts.map +1 -1
  51. package/types/models/auto/processing_auto.d.ts +1 -1
  52. package/types/models/auto/processing_auto.d.ts.map +1 -1
  53. package/types/models/clap/feature_extraction_clap.d.ts +1 -1
  54. package/types/models/clap/feature_extraction_clap.d.ts.map +1 -1
  55. package/types/models/detr/image_processing_detr.d.ts +11 -11
  56. package/types/models/detr/image_processing_detr.d.ts.map +1 -1
  57. package/types/models/donut/image_processing_donut.d.ts +1 -1
  58. package/types/models/donut/image_processing_donut.d.ts.map +1 -1
  59. package/types/models/florence2/processing_florence2.d.ts.map +1 -1
  60. package/types/models/idefics3/image_processing_idefics3.d.ts.map +1 -1
  61. package/types/models/idefics3/processing_idefics3.d.ts.map +1 -1
  62. package/types/models/janus/image_processing_janus.d.ts +1 -1
  63. package/types/models/janus/image_processing_janus.d.ts.map +1 -1
  64. package/types/models/janus/processing_janus.d.ts.map +1 -1
  65. package/types/models/maskformer/image_processing_maskformer.d.ts +8 -8
  66. package/types/models/maskformer/image_processing_maskformer.d.ts.map +1 -1
  67. package/types/models/mgp_str/processing_mgp_str.d.ts +2 -2
  68. package/types/models/mgp_str/processing_mgp_str.d.ts.map +1 -1
  69. package/types/models/owlvit/image_processing_owlvit.d.ts.map +1 -1
  70. package/types/models/paligemma/processing_paligemma.d.ts +12 -0
  71. package/types/models/paligemma/processing_paligemma.d.ts.map +1 -0
  72. package/types/models/processors.d.ts +1 -0
  73. package/types/models/pyannote/feature_extraction_pyannote.d.ts.map +1 -1
  74. package/types/models/pyannote/processing_pyannote.d.ts +1 -1
  75. package/types/models/pyannote/processing_pyannote.d.ts.map +1 -1
  76. package/types/models/qwen2_vl/processing_qwen2_vl.d.ts.map +1 -1
  77. package/types/models/rt_detr/image_processing_rt_detr.d.ts.map +1 -1
  78. package/types/models/sam/image_processing_sam.d.ts.map +1 -1
  79. package/types/models/seamless_m4t/feature_extraction_seamless_m4t.d.ts +1 -1
  80. package/types/models/seamless_m4t/feature_extraction_seamless_m4t.d.ts.map +1 -1
  81. package/types/models/segformer/image_processing_segformer.d.ts.map +1 -1
  82. package/types/models/speecht5/processing_speecht5.d.ts.map +1 -1
  83. package/types/models/swin2sr/image_processing_swin2sr.d.ts +1 -1
  84. package/types/models/swin2sr/image_processing_swin2sr.d.ts.map +1 -1
  85. package/types/models/vitmatte/image_processing_vitmatte.d.ts.map +1 -1
  86. package/types/models/vitpose/image_processing_vitpose.d.ts +1 -1
  87. package/types/models/vitpose/image_processing_vitpose.d.ts.map +1 -1
  88. package/types/models/wav2vec2/feature_extraction_wav2vec2.d.ts.map +1 -1
  89. package/types/models/wav2vec2/processing_wav2vec2.d.ts.map +1 -1
  90. package/types/models/wespeaker/feature_extraction_wespeaker.d.ts +1 -1
  91. package/types/models/wespeaker/feature_extraction_wespeaker.d.ts.map +1 -1
  92. package/types/models/whisper/feature_extraction_whisper.d.ts +1 -1
  93. package/types/models/whisper/feature_extraction_whisper.d.ts.map +1 -1
  94. package/types/models/whisper/generation_whisper.d.ts.map +1 -1
  95. package/types/models/whisper/processing_whisper.d.ts.map +1 -1
  96. package/types/models/yolos/image_processing_yolos.d.ts.map +1 -1
  97. package/types/models.d.ts +28 -4
  98. package/types/models.d.ts.map +1 -1
  99. package/types/ops/registry.d.ts.map +1 -1
  100. package/types/pipelines.d.ts +26 -51
  101. package/types/pipelines.d.ts.map +1 -1
  102. package/types/tokenizers.d.ts +10 -6
  103. package/types/tokenizers.d.ts.map +1 -1
  104. package/types/utils/audio.d.ts.map +1 -1
  105. package/types/utils/constants.d.ts.map +1 -1
  106. package/types/utils/core.d.ts +87 -22
  107. package/types/utils/core.d.ts.map +1 -1
  108. package/types/utils/data-structures.d.ts.map +1 -1
  109. package/types/utils/devices.d.ts.map +1 -1
  110. package/types/utils/dtypes.d.ts.map +1 -1
  111. package/types/utils/generic.d.ts.map +1 -1
  112. package/types/utils/hub.d.ts +3 -3
  113. package/types/utils/hub.d.ts.map +1 -1
  114. package/types/utils/image.d.ts +10 -1
  115. package/types/utils/image.d.ts.map +1 -1
  116. package/types/utils/maths.d.ts +10 -10
  117. package/types/utils/maths.d.ts.map +1 -1
  118. package/types/utils/tensor.d.ts +6 -6
  119. package/types/utils/tensor.d.ts.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huggingface/transformers",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "description": "State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!",
5
5
  "main": "./src/transformers.js",
6
6
  "types": "./types/transformers.d.ts",
@@ -21,12 +21,6 @@
21
21
  "default": "./dist/transformers.js"
22
22
  }
23
23
  },
24
- "imports": {
25
- "#onnxruntime-webgpu": {
26
- "node": "onnxruntime-web",
27
- "default": "onnxruntime-web/webgpu"
28
- }
29
- },
30
24
  "scripts": {
31
25
  "format": "prettier --write .",
32
26
  "format:check": "prettier --check .",
@@ -63,22 +57,23 @@
63
57
  "dependencies": {
64
58
  "@huggingface/jinja": "^0.3.2",
65
59
  "onnxruntime-node": "1.20.1",
66
- "onnxruntime-web": "1.20.1",
60
+ "onnxruntime-web": "1.21.0-dev.20241205-d27fecd3d3",
67
61
  "sharp": "^0.33.5"
68
62
  },
69
63
  "devDependencies": {
70
64
  "@types/jest": "^29.5.14",
71
- "@webgpu/types": "^0.1.44",
65
+ "@types/node": "^22.10.1",
66
+ "@webgpu/types": "^0.1.51",
72
67
  "catharsis": "github:xenova/catharsis",
73
68
  "jest": "^30.0.0-alpha.6",
74
69
  "jest-environment-node": "^30.0.0-alpha.6",
75
- "jsdoc-to-markdown": "^8.0.1",
76
- "prettier": "3.3.3",
77
- "typescript": "^5.2.2",
78
- "wavefile": "^11.0.0",
79
- "webpack": "^5.80.0",
80
- "webpack-cli": "^5.0.2",
81
- "webpack-dev-server": "^4.13.3"
70
+ "jsdoc-to-markdown": "^9.1.1",
71
+ "prettier": "3.4.2",
72
+ "typescript": "^5.7.2",
73
+ "wavefile": "11.0.0",
74
+ "webpack": "^5.97.1",
75
+ "webpack-cli": "^5.1.4",
76
+ "webpack-dev-server": "^5.1.0"
82
77
  },
83
78
  "files": [
84
79
  "src",
@@ -21,12 +21,7 @@ import { env, apis } from '../env.js';
21
21
  // NOTE: Import order matters here. We need to import `onnxruntime-node` before `onnxruntime-web`.
22
22
  // In either case, we select the default export if it exists, otherwise we use the named export.
23
23
  import * as ONNX_NODE from 'onnxruntime-node';
24
-
25
- // Use subpath-imports to ensure Node.js and browser interoperability.
26
- // See package.json and https://nodejs.org/api/packages.html#subpath-imports
27
- // for more information.
28
- // @ts-ignore
29
- import * as ONNX_WEB from '#onnxruntime-webgpu';
24
+ import * as ONNX_WEB from 'onnxruntime-web';
30
25
 
31
26
  export { Tensor } from 'onnxruntime-common';
32
27
 
@@ -68,7 +63,7 @@ if (ORT_SYMBOL in globalThis) {
68
63
  } else if (apis.IS_NODE_ENV) {
69
64
  ONNX = ONNX_NODE.default ?? ONNX_NODE;
70
65
 
71
- // Updated as of ONNX Runtime 1.18.0
66
+ // Updated as of ONNX Runtime 1.20.1
72
67
  // The following table lists the supported versions of ONNX Runtime Node.js binding provided with pre-built binaries.
73
68
  // | EPs/Platforms | Windows x64 | Windows arm64 | Linux x64 | Linux arm64 | MacOS x64 | MacOS arm64 |
74
69
  // | ------------- | ----------- | ------------- | ----------------- | ----------- | --------- | ----------- |
package/src/configs.js CHANGED
@@ -104,6 +104,7 @@ function getNormalizedConfig(config) {
104
104
  break;
105
105
  case 'llama':
106
106
  case 'olmo':
107
+ case 'olmo2':
107
108
  case 'mobilellm':
108
109
  case 'granite':
109
110
  case 'cohere':
package/src/env.js CHANGED
@@ -26,7 +26,7 @@ import fs from 'fs';
26
26
  import path from 'path';
27
27
  import url from 'url';
28
28
 
29
- const VERSION = '3.1.1';
29
+ const VERSION = '3.1.2';
30
30
 
31
31
  // Check if various APIs are available (depends on environment)
32
32
  const IS_BROWSER_ENV = typeof window !== "undefined" && typeof window.document !== "undefined";
@@ -0,0 +1,82 @@
1
+ import { Processor } from "../../base/processing_utils.js";
2
+ import { AutoImageProcessor } from "../auto/image_processing_auto.js";
3
+ import { AutoTokenizer } from "../../tokenizers.js";
4
+
5
+ const IMAGE_TOKEN = "<image>";
6
+
7
+ function build_string_from_input(
8
+ prompt,
9
+ bos_token,
10
+ image_seq_len,
11
+ image_token,
12
+ num_images,
13
+ ) {
14
+ return `${image_token.repeat(image_seq_len * num_images)}${bos_token}${prompt}\n`
15
+ }
16
+
17
+ export class PaliGemmaProcessor extends Processor {
18
+ static tokenizer_class = AutoTokenizer
19
+ static image_processor_class = AutoImageProcessor
20
+ static uses_processor_config = false;
21
+
22
+ /**
23
+ * @typedef {import('../../utils/image.js').RawImage} RawImage
24
+ */
25
+
26
+ // `images` is required, `text` is optional
27
+ async _call(/** @type {RawImage|RawImage[]} */ images, text = null, kwargs = {}) {
28
+ if (!text) {
29
+ console.warn(
30
+ "You are using PaliGemma without a text prefix. It will perform as a picture-captioning model."
31
+ )
32
+ text = ""
33
+ }
34
+
35
+ if (!Array.isArray(images)) {
36
+ images = [images]
37
+ }
38
+
39
+ if (!Array.isArray(text)) {
40
+ text = [text]
41
+ }
42
+
43
+ const bos_token = this.tokenizer.bos_token;
44
+ const image_seq_length = this.image_processor.config.image_seq_length;
45
+ let input_strings;
46
+ if (text.some((t) => t.includes(IMAGE_TOKEN))) {
47
+ input_strings = text.map(
48
+ sample => {
49
+ const expanded_sample = sample.replaceAll(IMAGE_TOKEN, IMAGE_TOKEN.repeat(image_seq_length));
50
+ const bos_rfind_index = expanded_sample.lastIndexOf(IMAGE_TOKEN);
51
+ const bos_index = bos_rfind_index === -1 ? 0 : bos_rfind_index + IMAGE_TOKEN.length;
52
+ return expanded_sample.slice(0, bos_index) + bos_token + expanded_sample.slice(bos_index) + "\n";
53
+ }
54
+ )
55
+ } else {
56
+ console.warn(
57
+ "You are passing both `text` and `images` to `PaliGemmaProcessor`. The processor expects special " +
58
+ "image tokens in the text, as many tokens as there are images per each text. It is recommended to " +
59
+ "add `<image>` tokens in the very beginning of your text. For this call, we will infer how many images " +
60
+ "each text has and add special tokens."
61
+ )
62
+
63
+ input_strings = text.map(
64
+ sample => build_string_from_input(
65
+ sample,
66
+ bos_token,
67
+ image_seq_length,
68
+ IMAGE_TOKEN,
69
+ images.length,
70
+ )
71
+ )
72
+ }
73
+
74
+ const text_inputs = this.tokenizer(input_strings, kwargs);
75
+ const image_inputs = await this.image_processor(images, kwargs);
76
+
77
+ return {
78
+ ...image_inputs,
79
+ ...text_inputs,
80
+ }
81
+ }
82
+ }
@@ -4,6 +4,7 @@ export * from './idefics3/processing_idefics3.js';
4
4
  export * from './janus/processing_janus.js';
5
5
  export * from './jina_clip/processing_jina_clip.js';
6
6
  export * from './owlvit/processing_owlvit.js';
7
+ export * from './paligemma/processing_paligemma.js';
7
8
  export * from './pyannote/processing_pyannote.js';
8
9
  export * from './qwen2_vl/processing_qwen2_vl.js';
9
10
  export * from './sam/processing_sam.js';
package/src/models.js CHANGED
@@ -558,7 +558,9 @@ async function decoderForward(self, model_inputs, is_encoder_decoder = false) {
558
558
  new_model_inputs.use_cache_branch = boolTensor(!!past_key_values);
559
559
  }
560
560
  if (session.inputNames.includes('position_ids') && new_model_inputs.attention_mask && !new_model_inputs.position_ids) {
561
- new_model_inputs.position_ids = createPositionIds(new_model_inputs, past_key_values);
561
+ // NOTE: Handle a special case for paligemma models, where positions are 1-indexed
562
+ const start_index = self.config.model_type === 'paligemma' ? 1 : 0;
563
+ new_model_inputs.position_ids = createPositionIds(new_model_inputs, past_key_values, start_index);
562
564
  }
563
565
 
564
566
  // Unpack the `past_key_values` object into model inputs
@@ -694,14 +696,14 @@ async function imageTextToTextForward(self, {
694
696
  * @param {Tensor} attention_mask
695
697
  * @returns {{data: BigInt64Array, dims: number[]}}
696
698
  */
697
- function cumsum_masked_fill(attention_mask) {
699
+ function cumsum_masked_fill(attention_mask, start_index = 0) {
698
700
  const [bz, seq_len] = attention_mask.dims;
699
701
  const attn_mask_data = attention_mask.data;
700
702
 
701
703
  const data = new BigInt64Array(attn_mask_data.length);
702
704
  for (let i = 0; i < bz; ++i) {
703
705
  const start = i * seq_len;
704
- let sum = BigInt(0);
706
+ let sum = BigInt(start_index);
705
707
  for (let j = 0; j < seq_len; ++j) {
706
708
  const index = start + j;
707
709
  if (attn_mask_data[index] === 0n) {
@@ -728,10 +730,10 @@ function cumsum_masked_fill(attention_mask) {
728
730
  * position_ids = position_ids[:, -input_ids.shape[1] :]
729
731
  * ```
730
732
  */
731
- function createPositionIds(model_inputs, past_key_values = null) {
733
+ function createPositionIds(model_inputs, past_key_values = null, start_index = 0) {
732
734
  const { input_ids, inputs_embeds, attention_mask } = model_inputs;
733
735
 
734
- const { data, dims } = cumsum_masked_fill(attention_mask);
736
+ const { data, dims } = cumsum_masked_fill(attention_mask, start_index);
735
737
  let position_ids = new Tensor('int64', data, dims);
736
738
  if (past_key_values) {
737
739
  const offset = -(input_ids ?? inputs_embeds).dims.at(1);
@@ -3548,6 +3550,30 @@ export class Florence2ForConditionalGeneration extends Florence2PreTrainedModel
3548
3550
  }
3549
3551
  }
3550
3552
 
3553
+ export class PaliGemmaPreTrainedModel extends PreTrainedModel {
3554
+ forward_params = [
3555
+ 'input_ids',
3556
+ // 'inputs_embeds',
3557
+ 'attention_mask',
3558
+ 'pixel_values',
3559
+ 'position_ids',
3560
+ 'past_key_values',
3561
+ ];
3562
+ }
3563
+
3564
+ export class PaliGemmaForConditionalGeneration extends PaliGemmaPreTrainedModel {
3565
+ _merge_input_ids_with_image_features(kwargs) {
3566
+ const vision_hidden_size = kwargs.image_features.dims.at(-1);
3567
+ const reshaped_image_hidden_states = kwargs.image_features.view(-1, vision_hidden_size);
3568
+
3569
+ return default_merge_input_ids_with_image_features({
3570
+ // @ts-ignore
3571
+ image_token_id: this.config.image_token_index,
3572
+ ...kwargs,
3573
+ image_features: reshaped_image_hidden_states,
3574
+ })
3575
+ }
3576
+ }
3551
3577
 
3552
3578
  //////////////////////////////////////////////////
3553
3579
  // Idefics3 Models
@@ -4086,6 +4112,13 @@ export class OlmoModel extends OlmoPreTrainedModel { }
4086
4112
  export class OlmoForCausalLM extends OlmoPreTrainedModel { }
4087
4113
  //////////////////////////////////////////////////
4088
4114
 
4115
+ //////////////////////////////////////////////////
4116
+ // OLMo2 models
4117
+ export class Olmo2PreTrainedModel extends PreTrainedModel { }
4118
+ export class Olmo2Model extends Olmo2PreTrainedModel { }
4119
+ export class Olmo2ForCausalLM extends Olmo2PreTrainedModel { }
4120
+ //////////////////////////////////////////////////
4121
+
4089
4122
 
4090
4123
  //////////////////////////////////////////////////
4091
4124
  // Granite models
@@ -4502,6 +4535,20 @@ export class ViTForImageClassification extends ViTPreTrainedModel {
4502
4535
  //////////////////////////////////////////////////
4503
4536
 
4504
4537
 
4538
+ //////////////////////////////////////////////////
4539
+ export class IJepaPreTrainedModel extends PreTrainedModel { }
4540
+ export class IJepaModel extends IJepaPreTrainedModel { }
4541
+ export class IJepaForImageClassification extends IJepaPreTrainedModel {
4542
+ /**
4543
+ * @param {any} model_inputs
4544
+ */
4545
+ async _call(model_inputs) {
4546
+ return new SequenceClassifierOutput(await super._call(model_inputs));
4547
+ }
4548
+ }
4549
+ //////////////////////////////////////////////////
4550
+
4551
+
4505
4552
  //////////////////////////////////////////////////
4506
4553
  export class VitPosePreTrainedModel extends PreTrainedModel { }
4507
4554
 
@@ -6772,6 +6819,7 @@ const MODEL_MAPPING_NAMES_ENCODER_ONLY = new Map([
6772
6819
  ['rt_detr', ['RTDetrModel', RTDetrModel]],
6773
6820
  ['table-transformer', ['TableTransformerModel', TableTransformerModel]],
6774
6821
  ['vit', ['ViTModel', ViTModel]],
6822
+ ['ijepa', ['IJepaModel', IJepaModel]],
6775
6823
  ['pvt', ['PvtModel', PvtModel]],
6776
6824
  ['vit_msn', ['ViTMSNModel', ViTMSNModel]],
6777
6825
  ['vit_mae', ['ViTMAEModel', ViTMAEModel]],
@@ -6836,6 +6884,7 @@ const MODEL_MAPPING_NAMES_DECODER_ONLY = new Map([
6836
6884
  ['codegen', ['CodeGenModel', CodeGenModel]],
6837
6885
  ['llama', ['LlamaModel', LlamaModel]],
6838
6886
  ['olmo', ['OlmoModel', OlmoModel]],
6887
+ ['olmo2', ['Olmo2Model', Olmo2Model]],
6839
6888
  ['mobilellm', ['MobileLLMModel', MobileLLMModel]],
6840
6889
  ['granite', ['GraniteModel', GraniteModel]],
6841
6890
  ['cohere', ['CohereModel', CohereModel]],
@@ -6927,6 +6976,7 @@ const MODEL_FOR_CAUSAL_LM_MAPPING_NAMES = new Map([
6927
6976
  ['codegen', ['CodeGenForCausalLM', CodeGenForCausalLM]],
6928
6977
  ['llama', ['LlamaForCausalLM', LlamaForCausalLM]],
6929
6978
  ['olmo', ['OlmoForCausalLM', OlmoForCausalLM]],
6979
+ ['olmo2', ['Olmo2ForCausalLM', Olmo2ForCausalLM]],
6930
6980
  ['mobilellm', ['MobileLLMForCausalLM', MobileLLMForCausalLM]],
6931
6981
  ['granite', ['GraniteForCausalLM', GraniteForCausalLM]],
6932
6982
  ['cohere', ['CohereForCausalLM', CohereForCausalLM]],
@@ -7000,6 +7050,7 @@ const MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES = new Map([
7000
7050
  ['florence2', ['Florence2ForConditionalGeneration', Florence2ForConditionalGeneration]],
7001
7051
  ['qwen2-vl', ['Qwen2VLForConditionalGeneration', Qwen2VLForConditionalGeneration]],
7002
7052
  ['idefics3', ['Idefics3ForConditionalGeneration', Idefics3ForConditionalGeneration]],
7053
+ ['paligemma', ['PaliGemmaForConditionalGeneration', PaliGemmaForConditionalGeneration]],
7003
7054
  ]);
7004
7055
 
7005
7056
  const MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES = new Map([
@@ -7008,6 +7059,7 @@ const MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES = new Map([
7008
7059
 
7009
7060
  const MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES = new Map([
7010
7061
  ['vit', ['ViTForImageClassification', ViTForImageClassification]],
7062
+ ['ijepa', ['IJepaForImageClassification', IJepaForImageClassification]],
7011
7063
  ['pvt', ['PvtForImageClassification', PvtForImageClassification]],
7012
7064
  ['vit_msn', ['ViTMSNForImageClassification', ViTMSNForImageClassification]],
7013
7065
  ['fastvit', ['FastViTForImageClassification', FastViTForImageClassification]],
package/src/tokenizers.js CHANGED
@@ -2605,6 +2605,12 @@ export class PreTrainedTokenizer extends Callable {
2605
2605
  this.unk_token = this.getToken('unk_token');
2606
2606
  this.unk_token_id = this.model.tokens_to_ids.get(this.unk_token);
2607
2607
 
2608
+ this.bos_token = this.getToken('bos_token');
2609
+ this.bos_token_id = this.model.tokens_to_ids.get(this.bos_token);
2610
+
2611
+ this.eos_token = this.getToken('eos_token');
2612
+ this.eos_token_id = this.model.tokens_to_ids.get(this.eos_token);
2613
+
2608
2614
  this.model_max_length = tokenizerConfig.model_max_length;
2609
2615
 
2610
2616
  /** @type {boolean} Whether or not to strip the text when tokenizing (removing excess spaces before and after the string). */
@@ -3577,6 +3583,11 @@ export class WhisperTokenizer extends PreTrainedTokenizer {
3577
3583
  let chunk = new_chunk();
3578
3584
  let time_offset = 0.0;
3579
3585
  const timestamp_begin = this.timestamp_begin;
3586
+ // Whisper timestamp tokens start from 0.00 and go to timestamp 30.00 in 0.02 increments.
3587
+ // We can calculate the last time stamp token as timestamp_begin plus the number of tokens
3588
+ // tokens from 0.00 to 30.00 which is 1500.
3589
+ const total_timestamp_tokens = 1500; // (30.00 - 0.00) / 0.02
3590
+ const timestamp_end = timestamp_begin + total_timestamp_tokens;
3580
3591
 
3581
3592
  let previous_tokens = [];
3582
3593
  let previous_token_timestamps = [];
@@ -3664,7 +3675,7 @@ export class WhisperTokenizer extends PreTrainedTokenizer {
3664
3675
  } else {
3665
3676
  // 2/ This is a regular special token, ignoring it
3666
3677
  }
3667
- } else if (token >= timestamp_begin) {
3678
+ } else if (token >= timestamp_begin && token <= timestamp_end) {
3668
3679
  // 3/ Timestamp token
3669
3680
  const time = (token - timestamp_begin) * time_precision + time_offset;
3670
3681
  const rounded_time = round(time, 2);
package/src/utils/core.js CHANGED
@@ -9,15 +9,45 @@
9
9
  */
10
10
 
11
11
  /**
12
- * @typedef {Object} ProgressInfo
13
- * @property {'initiate' | 'download' | 'progress' | 'done'} status The status of the progress item.
14
- * @property {string} name This can be either:
15
- * - a string, the *model id* of a model repo on huggingface.co.
16
- * - a path to a *directory* potentially containing the file.
17
- * @property {string} file The name of the file
18
- * @property {number} [progress] A number between 0 and 100. Only available for the 'progress' status.
19
- * @property {number} [loaded] The number of bytes loaded. Only available for the 'progress' status.
20
- * @property {number} [total] The total number of bytes to be loaded. Only available for the 'progress' status.
12
+ * @typedef {Object} InitiateProgressInfo
13
+ * @property {'initiate'} status
14
+ * @property {string} name The model id or directory path.
15
+ * @property {string} file The name of the file.
16
+ */
17
+
18
+ /**
19
+ * @typedef {Object} DownloadProgressInfo
20
+ * @property {'download'} status
21
+ * @property {string} name The model id or directory path.
22
+ * @property {string} file The name of the file.
23
+ */
24
+
25
+ /**
26
+ * @typedef {Object} ProgressStatusInfo
27
+ * @property {'progress'} status
28
+ * @property {string} name The model id or directory path.
29
+ * @property {string} file The name of the file.
30
+ * @property {number} progress A number between 0 and 100.
31
+ * @property {number} loaded The number of bytes loaded.
32
+ * @property {number} total The total number of bytes to be loaded.
33
+ */
34
+
35
+ /**
36
+ * @typedef {Object} DoneProgressInfo
37
+ * @property {'done'} status
38
+ * @property {string} name The model id or directory path.
39
+ * @property {string} file The name of the file.
40
+ */
41
+
42
+ /**
43
+ * @typedef {Object} ReadyProgressInfo
44
+ * @property {'ready'} status
45
+ * @property {string} task The loaded task.
46
+ * @property {string} model The loaded model.
47
+ */
48
+
49
+ /**
50
+ * @typedef {InitiateProgressInfo | DownloadProgressInfo | ProgressStatusInfo | DoneProgressInfo | ReadyProgressInfo} ProgressInfo
21
51
  */
22
52
 
23
53
  /**
package/src/utils/hub.js CHANGED
@@ -504,13 +504,6 @@ export async function getModelFile(path_or_repo_id, filename, fatal = true, opti
504
504
  file: filename
505
505
  })
506
506
 
507
- /** @type {import('./core.js').ProgressInfo} */
508
- const progressInfo = {
509
- status: 'progress',
510
- name: path_or_repo_id,
511
- file: filename
512
- }
513
-
514
507
  /** @type {Uint8Array} */
515
508
  let buffer;
516
509
 
@@ -530,7 +523,9 @@ export async function getModelFile(path_or_repo_id, filename, fatal = true, opti
530
523
 
531
524
  // For completeness, we still fire the final progress callback
532
525
  dispatchCallback(options.progress_callback, {
533
- ...progressInfo,
526
+ status: 'progress',
527
+ name: path_or_repo_id,
528
+ file: filename,
534
529
  progress: 100,
535
530
  loaded: buffer.length,
536
531
  total: buffer.length,
@@ -538,7 +533,9 @@ export async function getModelFile(path_or_repo_id, filename, fatal = true, opti
538
533
  } else {
539
534
  buffer = await readResponse(response, data => {
540
535
  dispatchCallback(options.progress_callback, {
541
- ...progressInfo,
536
+ status: 'progress',
537
+ name: path_or_repo_id,
538
+ file: filename,
542
539
  ...data,
543
540
  })
544
541
  })
@@ -595,12 +592,11 @@ export async function getModelJSON(modelPath, fileName, fatal = true, options =
595
592
 
596
593
  return JSON.parse(jsonData);
597
594
  }
598
-
599
595
  /**
600
596
  * Read and track progress when reading a Response object
601
597
  *
602
- * @param {any} response The Response object to read
603
- * @param {function} progress_callback The function to call with progress updates
598
+ * @param {Response|FileResponse} response The Response object to read
599
+ * @param {(data: {progress: number, loaded: number, total: number}) => void} progress_callback The function to call with progress updates
604
600
  * @returns {Promise<Uint8Array>} A Promise that resolves with the Uint8Array buffer
605
601
  */
606
602
  async function readResponse(response, progress_callback) {
@@ -303,6 +303,46 @@ export class RawImage {
303
303
  return this._update(newData, this.width, this.height, 4);
304
304
  }
305
305
 
306
+ /**
307
+ * Apply an alpha mask to the image. Operates in place.
308
+ * @param {RawImage} mask The mask to apply. It should have a single channel.
309
+ * @returns {RawImage} The masked image.
310
+ * @throws {Error} If the mask is not the same size as the image.
311
+ * @throws {Error} If the image does not have 4 channels.
312
+ * @throws {Error} If the mask is not a single channel.
313
+ */
314
+ putAlpha(mask) {
315
+ if (mask.width !== this.width || mask.height !== this.height) {
316
+ throw new Error(`Expected mask size to be ${this.width}x${this.height}, but got ${mask.width}x${mask.height}`);
317
+ }
318
+ if (mask.channels !== 1) {
319
+ throw new Error(`Expected mask to have 1 channel, but got ${mask.channels}`);
320
+ }
321
+
322
+ const this_data = this.data;
323
+ const mask_data = mask.data;
324
+ const num_pixels = this.width * this.height;
325
+ if (this.channels === 3) {
326
+ // Convert to RGBA and simultaneously apply mask to alpha channel
327
+ const newData = new Uint8ClampedArray(num_pixels * 4);
328
+ for (let i = 0, in_offset = 0, out_offset = 0; i < num_pixels; ++i) {
329
+ newData[out_offset++] = this_data[in_offset++];
330
+ newData[out_offset++] = this_data[in_offset++];
331
+ newData[out_offset++] = this_data[in_offset++];
332
+ newData[out_offset++] = mask_data[i];
333
+ }
334
+ return this._update(newData, this.width, this.height, 4);
335
+
336
+ } else if (this.channels === 4) {
337
+ // Apply mask to alpha channel in place
338
+ for (let i = 0; i < num_pixels; ++i) {
339
+ this_data[4 * i + 3] = mask_data[i];
340
+ }
341
+ return this;
342
+ }
343
+ throw new Error(`Expected image to have 3 or 4 channels, but got ${this.channels}`);
344
+ }
345
+
306
346
  /**
307
347
  * Resize the image to the given dimensions. This method uses the canvas API to perform the resizing.
308
348
  * @param {number} width The width of the new image. `null` or `-1` will preserve the aspect ratio.
@@ -11,7 +11,7 @@ export function deviceToExecutionProviders(device?: import("../utils/devices.js"
11
11
  * @param {Object} session_config ONNX inference session configuration.
12
12
  * @returns {Promise<import('onnxruntime-common').InferenceSession & { config: Object}>} The ONNX inference session.
13
13
  */
14
- export function createInferenceSession(buffer: Uint8Array, session_options: import('onnxruntime-common').InferenceSession.SessionOptions, session_config: any): Promise<import('onnxruntime-common').InferenceSession & {
14
+ export function createInferenceSession(buffer: Uint8Array, session_options: import("onnxruntime-common").InferenceSession.SessionOptions, session_config: any): Promise<import("onnxruntime-common").InferenceSession & {
15
15
  config: any;
16
16
  }>;
17
17
  /**
@@ -26,5 +26,5 @@ export function isONNXTensor(x: any): boolean;
26
26
  */
27
27
  export function isONNXProxy(): boolean;
28
28
  export { Tensor } from "onnxruntime-common";
29
- export type ONNXExecutionProviders = import('onnxruntime-common').InferenceSession.ExecutionProviderConfig;
29
+ export type ONNXExecutionProviders = import("onnxruntime-common").InferenceSession.ExecutionProviderConfig;
30
30
  //# sourceMappingURL=onnx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"onnx.d.ts","sourceRoot":"","sources":["../../src/backends/onnx.js"],"names":[],"mappings":"AA+GA;;;;GAIG;AACH,oDAHW,OAAO,qBAAqB,EAAE,UAAU,GAAC,MAAM,GAAC,IAAI,GAClD,sBAAsB,EAAE,CAqBpC;AAWD;;;;;;GAMG;AACH,+CALW,UAAU,mBACV,OAAO,oBAAoB,EAAE,gBAAgB,CAAC,cAAc,wBAE1D,QAAQ,OAAO,oBAAoB,EAAE,gBAAgB,GAAG;IAAE,MAAM,MAAQ;CAAC,CAAC,CActF;AAED;;;;GAIG;AACH,gCAHW,GAAG,GACD,OAAO,CAInB;AA+BD;;;GAGG;AACH,+BAFa,OAAO,CAKnB;;qCAnLY,OAAO,oBAAoB,EAAE,gBAAgB,CAAC,uBAAuB"}
1
+ {"version":3,"file":"onnx.d.ts","sourceRoot":"","sources":["../../src/backends/onnx.js"],"names":[],"mappings":"AA0GA;;;;GAIG;AACH,oDAHW,OAAO,qBAAqB,EAAE,UAAU,GAAC,MAAM,GAAC,IAAI,GAClD,sBAAsB,EAAE,CAqBpC;AAWD;;;;;;GAMG;AACH,+CALW,UAAU,mBACV,OAAO,oBAAoB,EAAE,gBAAgB,CAAC,cAAc,wBAE1D,OAAO,CAAC,OAAO,oBAAoB,EAAE,gBAAgB,GAAG;IAAE,MAAM,MAAQ;CAAC,CAAC,CActF;AAED;;;;GAIG;AACH,gCAHW,GAAG,GACD,OAAO,CAInB;AA+BD;;;GAGG;AACH,+BAFa,OAAO,CAKnB;;qCAnLY,OAAO,oBAAoB,EAAE,gBAAgB,CAAC,uBAAuB"}
@@ -28,7 +28,7 @@ export class FeatureExtractor extends FeatureExtractor_base {
28
28
  *
29
29
  * @returns {Promise<FeatureExtractor>} A new instance of the Processor class.
30
30
  */
31
- static from_pretrained(pretrained_model_name_or_path: string, options: import('../utils/hub.js').PretrainedOptions): Promise<FeatureExtractor>;
31
+ static from_pretrained(pretrained_model_name_or_path: string, options: import("../utils/hub.js").PretrainedOptions): Promise<FeatureExtractor>;
32
32
  /**
33
33
  * Constructs a new FeatureExtractor instance.
34
34
  *
@@ -1 +1 @@
1
- {"version":3,"file":"feature_extraction_utils.d.ts","sourceRoot":"","sources":["../../src/base/feature_extraction_utils.js"],"names":[],"mappings":"AAwCA;;;;;GAKG;AACH,6CAJW,GAAG,qBACH,MAAM,QAUhB;;;;;AAjDD;;GAEG;AACH;IAWI;;;;;;;;;;;;;;OAcG;IACH,sDATW,MAAM,WAKN,OAAO,iBAAiB,EAAE,iBAAiB,GAEzC,QAAQ,gBAAgB,CAAC,CAKrC;IA5BD;;;;OAIG;IACH,yBAGC;IADG,YAAoB;CAsB3B"}
1
+ {"version":3,"file":"feature_extraction_utils.d.ts","sourceRoot":"","sources":["../../src/base/feature_extraction_utils.js"],"names":[],"mappings":"AAwCA;;;;;GAKG;AACH,6CAJW,GAAG,qBACH,MAAM,QAUhB;;KAnDuC,GAAG;UAG5B,GAAG;;AADlB;;GAEG;AACH;IAWI;;;;;;;;;;;;;;OAcG;IACH,sDATW,MAAM,WAKN,OAAO,iBAAiB,EAAE,iBAAiB,GAEzC,OAAO,CAAC,gBAAgB,CAAC,CAKrC;IA5BD;;;;OAIG;IACH,yBAGC;IADG,YAAoB;CAsB3B"}
@@ -102,7 +102,7 @@ export class ImageProcessor extends ImageProcessor_base {
102
102
  *
103
103
  * @returns {Promise<ImageProcessor>} A new instance of the Processor class.
104
104
  */
105
- static from_pretrained(pretrained_model_name_or_path: string, options: import('../utils/hub.js').PretrainedOptions): Promise<ImageProcessor>;
105
+ static from_pretrained(pretrained_model_name_or_path: string, options: import("../utils/hub.js").PretrainedOptions): Promise<ImageProcessor>;
106
106
  /**
107
107
  * Constructs a new `ImageProcessor`.
108
108
  * @param {ImageProcessorConfig} config The configuration object.
@@ -160,7 +160,7 @@ export class ImageProcessor extends ImageProcessor_base {
160
160
  width: number;
161
161
  height: number;
162
162
  } | number, { mode, center, constant_values, }?: {
163
- mode?: 'constant' | 'symmetric';
163
+ mode?: "constant" | "symmetric";
164
164
  center?: boolean;
165
165
  constant_values?: number | number[];
166
166
  }): [Float32Array, number[]];
@@ -1 +1 @@
1
- {"version":3,"file":"image_processors_utils.d.ts","sourceRoot":"","sources":["../../src/base/image_processors_utils.js"],"names":[],"mappings":"AA+EA;;;;;;;;;GASG;AACH;IAP2B,MAAM,EAAtB,MAAM;IACU,UAAU,EAA1B,MAAM;eACN,MAAM,iBACN,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,iBAClB,OAAO,GACN,KAAQ,CAwEnB;AAGD;;;;;;GAMG;AACH,gFAJW,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAEhB;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAC,EAAE,CAwDtD;AAkPD;;;;;;;;;GASG;AACH,6EAPW,MAAM,mBACN,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BAJW,QAAQ,iGAEN,OAAO;;;;uBAVN,WAAW;;;;6BACX,WAAW;;;;sBACX,MAAM;MAQmB,CAsHtC;IAED;;;;;;;OAOG;IACH,cAJW,QAAQ,EAAE,WACP,GAAG,EAAA,GACJ,OAAO,CAAC,oBAAoB,CAAC,CAqBzC;CAsBJ;;;;;0BArjCY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;;;;;kBAM9B,MAAM;;;;oBACN,WAAW,EAAE;;;;0BACb,WAAW,EAAE;;;;;;;;;;;;;iBAgiBb,MAAM,EAAE;;;;gBACR,MAAM,EAAE;;;;iBACR,OAAO;;;;qBACP,MAAM;;;;mBACN,OAAO;;;;gBACP,OAAO;;;;eACP,MAAM;;;;WACN,MAAM,MAAO;;;;iBACb,MAAM,MAAO;;;;;4BACb,OAAO;;;;;qBAEP,OAAO;;;;mBAEP,OAAO;;;;;wBACP,OAAO;;;;;yBAEP,MAAM;;;;WAGN,MAAM,EAAE;;;;UACR,MAAM,EAAE;;uBAtkBqB,oBAAoB;yBAEtC,mBAAmB"}
@@ -39,15 +39,15 @@ export class Processor extends Processor_base {
39
39
  /**
40
40
  * @returns {import('./image_processors_utils.js').ImageProcessor|undefined} The image processor of the processor, if it exists.
41
41
  */
42
- get image_processor(): import("./image_processors_utils.js").ImageProcessor;
42
+ get image_processor(): import("./image_processors_utils.js").ImageProcessor | undefined;
43
43
  /**
44
44
  * @returns {import('../tokenizers.js').PreTrainedTokenizer|undefined} The tokenizer of the processor, if it exists.
45
45
  */
46
- get tokenizer(): import("../tokenizers.js").PreTrainedTokenizer;
46
+ get tokenizer(): import("../tokenizers.js").PreTrainedTokenizer | undefined;
47
47
  /**
48
48
  * @returns {import('./feature_extraction_utils.js').FeatureExtractor|undefined} The feature extractor of the processor, if it exists.
49
49
  */
50
- get feature_extractor(): import("./feature_extraction_utils.js").FeatureExtractor;
50
+ get feature_extractor(): import("./feature_extraction_utils.js").FeatureExtractor | undefined;
51
51
  apply_chat_template(messages: any, options?: {}): string | number[] | number[][] | import("../transformers.js").Tensor | {
52
52
  /**
53
53
  * List of token ids to be fed to a model.
@@ -75,6 +75,6 @@ export class Processor extends Processor_base {
75
75
  * Additional processor-specific properties.
76
76
  */
77
77
  export type ProcessorProperties = any;
78
- export type PretrainedProcessorOptions = import('../utils/hub.js').PretrainedOptions & ProcessorProperties;
78
+ export type PretrainedProcessorOptions = import("../utils/hub.js").PretrainedOptions & ProcessorProperties;
79
79
  export {};
80
80
  //# sourceMappingURL=processing_utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"processing_utils.d.ts","sourceRoot":"","sources":["../../src/base/processing_utils.js"],"names":[],"mappings":";;;;AA2BA;;;GAGG;AAGH;;GAEG;AACH;IACI,yBAIC;IACD,sCAAqC;IAoErC;;;;;;;;;;;;;;OAcG;IACH,sDATW,MAAM,WAKN,0BAA0B,GAExB,QAAQ,SAAS,CAAC,CAoB9B;IAnGD;;;;OAIG;IACH,qCAFW,OAAO,MAAM,MAAS,EAMhC;IAFG,YAAoB;IACpB,gCAA4B;IAGhC;;OAEG;IACH,4EAEC;IAED;;OAEG;IACH,gEAEC;IAED;;OAEG;IACH,kFAEC;IAED;;;;;;;;;;;;;MAQC;IAED,uCAKC;IAGD;;;;;OAKG;IACH,aAJW,GAAG,WACA,GAAG,KACJ,QAAQ,GAAG,CAAC,CASxB;CAqCJ;;;;;yCAnHY,OAAO,iBAAiB,EAAE,iBAAiB,GAAG,mBAAmB"}
1
+ {"version":3,"file":"processing_utils.d.ts","sourceRoot":"","sources":["../../src/base/processing_utils.js"],"names":[],"mappings":";KAIsD,GAAG;UACxD,GAAE;;AAsBH;;;GAGG;AAGH;;GAEG;AACH;IACI,yBAIC;IACD,sCAAqC;IAoErC;;;;;;;;;;;;;;OAcG;IACH,sDATW,MAAM,WAKN,0BAA0B,GAExB,OAAO,CAAC,SAAS,CAAC,CAoB9B;IAnGD;;;;OAIG;IACH,qCAFW,MAAM,CAAC,MAAM,MAAS,EAMhC;IAFG,YAAoB;IACpB,gCAA4B;IAGhC;;OAEG;IACH,uBAFa,OAAO,6BAA6B,EAAE,cAAc,GAAC,SAAS,CAI1E;IAED;;OAEG;IACH,iBAFa,OAAO,kBAAkB,EAAE,mBAAmB,GAAC,SAAS,CAIpE;IAED;;OAEG;IACH,yBAFa,OAAO,+BAA+B,EAAE,gBAAgB,GAAC,SAAS,CAI9E;IAED;;;;;;;;;;;;;MAQC;IAED,uCAKC;IAGD;;;;;OAKG;IACH,aAJW,GAAG,WACA,GAAG,EAAA,GACJ,OAAO,CAAC,GAAG,CAAC,CASxB;CAqCJ;;;;;yCAnHY,OAAO,iBAAiB,EAAE,iBAAiB,GAAG,mBAAmB"}