@huggingface/transformers 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (63) hide show
  1. package/README.md +20 -9
  2. package/dist/ort-wasm-simd-threaded.jsep.wasm +0 -0
  3. package/dist/transformers.cjs +2581 -2556
  4. package/dist/transformers.cjs.map +1 -1
  5. package/dist/transformers.js +3542 -3453
  6. package/dist/transformers.js.map +1 -1
  7. package/dist/transformers.min.cjs +37 -43
  8. package/dist/transformers.min.cjs.map +1 -1
  9. package/dist/transformers.min.js +39 -40
  10. package/dist/transformers.min.js.map +1 -1
  11. package/dist/transformers.min.mjs +63 -70
  12. package/dist/transformers.min.mjs.map +1 -1
  13. package/dist/transformers.mjs +2630 -2576
  14. package/dist/transformers.mjs.map +1 -1
  15. package/package.json +23 -13
  16. package/src/backends/onnx.js +98 -36
  17. package/src/configs.js +19 -4
  18. package/src/env.js +9 -9
  19. package/src/generation/logits_process.js +40 -37
  20. package/src/generation/streamers.js +3 -3
  21. package/src/models.js +310 -515
  22. package/src/ops/registry.js +14 -3
  23. package/src/pipelines.js +5 -4
  24. package/src/processors.js +390 -351
  25. package/src/tokenizers.js +139 -174
  26. package/src/utils/core.js +12 -0
  27. package/src/utils/data-structures.js +13 -11
  28. package/src/utils/devices.js +15 -4
  29. package/src/utils/dtypes.js +1 -3
  30. package/src/utils/hub.js +18 -17
  31. package/src/utils/maths.js +14 -5
  32. package/src/utils/tensor.js +60 -13
  33. package/types/backends/onnx.d.ts +6 -5
  34. package/types/backends/onnx.d.ts.map +1 -1
  35. package/types/configs.d.ts +29 -3
  36. package/types/configs.d.ts.map +1 -1
  37. package/types/env.d.ts +6 -2
  38. package/types/env.d.ts.map +1 -1
  39. package/types/generation/logits_process.d.ts.map +1 -1
  40. package/types/models.d.ts +115 -288
  41. package/types/models.d.ts.map +1 -1
  42. package/types/ops/registry.d.ts +6 -6
  43. package/types/ops/registry.d.ts.map +1 -1
  44. package/types/pipelines.d.ts +1 -2
  45. package/types/pipelines.d.ts.map +1 -1
  46. package/types/processors.d.ts +55 -51
  47. package/types/processors.d.ts.map +1 -1
  48. package/types/tokenizers.d.ts +23 -32
  49. package/types/tokenizers.d.ts.map +1 -1
  50. package/types/utils/core.d.ts +7 -0
  51. package/types/utils/core.d.ts.map +1 -1
  52. package/types/utils/data-structures.d.ts +6 -6
  53. package/types/utils/data-structures.d.ts.map +1 -1
  54. package/types/utils/devices.d.ts +11 -1
  55. package/types/utils/devices.d.ts.map +1 -1
  56. package/types/utils/dtypes.d.ts +0 -3
  57. package/types/utils/dtypes.d.ts.map +1 -1
  58. package/types/utils/hub.d.ts +2 -41
  59. package/types/utils/hub.d.ts.map +1 -1
  60. package/types/utils/maths.d.ts +2 -2
  61. package/types/utils/maths.d.ts.map +1 -1
  62. package/types/utils/tensor.d.ts +27 -1
  63. package/types/utils/tensor.d.ts.map +1 -1
package/src/models.js CHANGED
@@ -146,7 +146,8 @@ const MODEL_CLASS_TO_NAME_MAPPING = new Map();
146
146
  * @private
147
147
  */
148
148
  async function getSession(pretrained_model_name_or_path, fileName, options) {
149
- let device = options.device;
149
+ const custom_config = options.config?.['transformers.js_config'] ?? {};
150
+ let device = options.device ?? custom_config.device;
150
151
  if (device && typeof device !== 'string') {
151
152
  if (device.hasOwnProperty(fileName)) {
152
153
  device = device[fileName];
@@ -157,49 +158,63 @@ async function getSession(pretrained_model_name_or_path, fileName, options) {
157
158
  }
158
159
 
159
160
  // If the device is not specified, we use the default (supported) execution providers.
160
- const executionProviders = deviceToExecutionProviders(
161
- /** @type {import("./utils/devices.js").DeviceType|null} */(device)
161
+ const selectedDevice = /** @type {import("./utils/devices.js").DeviceType} */(
162
+ device ?? (apis.IS_NODE_ENV ? 'cpu' : 'wasm')
162
163
  );
164
+ const executionProviders = deviceToExecutionProviders(selectedDevice);
163
165
 
164
166
  // If options.dtype is specified, we use it to choose the suffix for the model file.
165
167
  // Otherwise, we use the default dtype for the device.
166
- let dtype = options.dtype;
168
+ let dtype = options.dtype ?? custom_config.dtype;
167
169
  if (typeof dtype !== 'string') {
168
170
  if (dtype && dtype.hasOwnProperty(fileName)) {
169
171
  dtype = dtype[fileName];
170
172
  } else {
171
- dtype = DEFAULT_DEVICE_DTYPE_MAPPING[executionProviders[0]];
172
- console.warn(`dtype not specified for "${fileName}". Using the default dtype for this device (${dtype}).`);
173
+ dtype = DEFAULT_DEVICE_DTYPE_MAPPING[selectedDevice] ?? DATA_TYPES.fp32;
174
+ console.warn(`dtype not specified for "${fileName}". Using the default dtype (${dtype}) for this device (${selectedDevice}).`);
173
175
  }
174
176
  }
175
177
 
176
- if (!DEFAULT_DTYPE_SUFFIX_MAPPING.hasOwnProperty(dtype)) {
177
- throw new Error(`Invalid dtype: ${dtype}. Should be one of: ${Object.keys(DATA_TYPES).join(', ')}`);
178
- } else if (dtype === DATA_TYPES.fp16 && device === 'webgpu' && !(await isWebGpuFp16Supported())) {
179
- throw new Error(`The device (${device}) does not support fp16.`);
178
+ const selectedDtype = /** @type {import("./utils/dtypes.js").DataType} */(dtype);
179
+
180
+ if (!DEFAULT_DTYPE_SUFFIX_MAPPING.hasOwnProperty(selectedDtype)) {
181
+ throw new Error(`Invalid dtype: ${selectedDtype}. Should be one of: ${Object.keys(DATA_TYPES).join(', ')}`);
182
+ } else if (selectedDtype === DATA_TYPES.fp16 && selectedDevice === 'webgpu' && !(await isWebGpuFp16Supported())) {
183
+ throw new Error(`The device (${selectedDevice}) does not support fp16.`);
180
184
  }
181
185
 
182
186
  // Construct the model file name
183
- const suffix = DEFAULT_DTYPE_SUFFIX_MAPPING[dtype];
187
+ const suffix = DEFAULT_DTYPE_SUFFIX_MAPPING[selectedDtype];
184
188
  const modelFileName = `${options.subfolder ?? ''}/${fileName}${suffix}.onnx`;
185
189
 
186
- const session_options = { ...options.session_options } ?? {};
190
+ const session_options = { ...options.session_options };
187
191
 
188
192
  // Overwrite `executionProviders` if not specified
189
193
  session_options.executionProviders ??= executionProviders;
190
194
 
195
+ // Overwrite `freeDimensionOverrides` if specified in config and not set in session options
196
+ const free_dimension_overrides = custom_config.free_dimension_overrides;
197
+ if (free_dimension_overrides) {
198
+ session_options.freeDimensionOverrides ??= free_dimension_overrides;
199
+ } else if (selectedDevice.startsWith('webnn') && !session_options.freeDimensionOverrides) {
200
+ console.warn(
201
+ 'WebNN does not currently support dynamic shapes and requires `free_dimension_overrides` to be set in config.json as a field within "transformers.js_config". ' +
202
+ 'When `free_dimension_overrides` is not set, you may experience significant performance degradation.'
203
+ );
204
+ }
191
205
 
192
206
  const bufferPromise = getModelFile(pretrained_model_name_or_path, modelFileName, true, options);
193
207
 
194
208
  // handle onnx external data files
209
+ const use_external_data_format = options.use_external_data_format ?? custom_config.use_external_data_format;
195
210
  /** @type {Promise<{path: string, data: Uint8Array}>[]} */
196
211
  let externalDataPromises = [];
197
- if (options.use_external_data_format && (
198
- options.use_external_data_format === true ||
212
+ if (use_external_data_format && (
213
+ use_external_data_format === true ||
199
214
  (
200
- typeof options.use_external_data_format === 'object' &&
201
- options.use_external_data_format.hasOwnProperty(fileName) &&
202
- options.use_external_data_format[fileName] === true
215
+ typeof use_external_data_format === 'object' &&
216
+ use_external_data_format.hasOwnProperty(fileName) &&
217
+ use_external_data_format[fileName] === true
203
218
  )
204
219
  )) {
205
220
  if (apis.IS_NODE_ENV) {
@@ -227,12 +242,13 @@ async function getSession(pretrained_model_name_or_path, fileName, options) {
227
242
  session_options.externalData = await Promise.all(externalDataPromises);
228
243
  }
229
244
 
230
- if (device === 'webgpu') {
245
+ if (selectedDevice === 'webgpu') {
231
246
  const shapes = getKeyValueShapes(options.config, {
232
247
  prefix: 'present',
233
248
  });
234
249
  if (Object.keys(shapes).length > 0 && !isONNXProxy()) {
235
250
  // Only set preferredOutputLocation if shapes are present and we aren't proxying ONNX
251
+ /** @type {Record<string, import('onnxruntime-common').Tensor.DataLocation>} */
236
252
  const preferredOutputLocation = {};
237
253
  for (const key in shapes) {
238
254
  preferredOutputLocation[key] = 'gpu-buffer';
@@ -264,6 +280,23 @@ async function constructSessions(pretrained_model_name_or_path, names, options)
264
280
  ));
265
281
  }
266
282
 
283
+ /**
284
+ * Helper function to load multiple optional configuration files
285
+ * @param {string} pretrained_model_name_or_path The path to the directory containing the config file.
286
+ * @param {Record<string, string>} names The names of the config files to load.
287
+ * @param {import('./utils/hub.js').PretrainedModelOptions} options Additional options for loading the configs.
288
+ * @returns {Promise<Record<string, any>>} A Promise that resolves to a dictionary of configuration objects.
289
+ * @private
290
+ */
291
+ async function getOptionalConfigs(pretrained_model_name_or_path, names, options) {
292
+ return Object.fromEntries(await Promise.all(
293
+ Object.keys(names).map(async (name) => {
294
+ const config = await getModelJSON(pretrained_model_name_or_path, names[name], false, options);
295
+ return [name, config];
296
+ })
297
+ ));
298
+ }
299
+
267
300
  /**
268
301
  * Validate model inputs
269
302
  * @param {Object} session The InferenceSession object that will be run.
@@ -390,37 +423,6 @@ function toI64Tensor(items) {
390
423
  }
391
424
  }
392
425
 
393
- /**
394
- * Prepares an attention mask for a sequence of tokens based on configuration options.
395
- * @param {Object} self The calling object instance.
396
- * @param {Tensor} tokens The input tokens.
397
- * @returns {Tensor} The attention mask tensor.
398
- * @private
399
- */
400
- function prepareAttentionMask(self, tokens) {
401
-
402
- // Prepare attention mask
403
- let pad_token_id = self.config.pad_token_id ?? null;
404
- let eos_token_id = self.config.eos_token_id ?? null;
405
- if (isIntegralNumber(eos_token_id)) {
406
- eos_token_id = [eos_token_id];
407
- }
408
-
409
- let is_pad_token_in_inputs = tokens.indexOf(pad_token_id) !== -1;
410
- let is_pad_token_not_equal_to_eos_token_id = (eos_token_id === null) || !eos_token_id.includes(pad_token_id)
411
-
412
- if (is_pad_token_in_inputs && is_pad_token_not_equal_to_eos_token_id) {
413
- let data = BigInt64Array.from(
414
- // Note: != so that int matches bigint
415
- // @ts-ignore
416
- tokens.data.map(x => x != pad_token_id)
417
- )
418
- return new Tensor('int64', data, tokens.dims)
419
- } else {
420
- return ones_like(tokens);
421
- }
422
- }
423
-
424
426
  /**
425
427
  * Creates a boolean tensor with a single value.
426
428
  * @param {boolean} value The value of the tensor.
@@ -691,8 +693,8 @@ function image_text_to_text_prepare_inputs_for_generation(self, ...args) {
691
693
  } else {
692
694
  return decoder_prepare_inputs_for_generation(self, ...args);
693
695
  }
694
-
695
696
  }
697
+
696
698
  //////////////////////////////////////////////////
697
699
 
698
700
  //////////////////////////////////////////////////
@@ -706,12 +708,14 @@ export class PreTrainedModel extends Callable {
706
708
  * Creates a new instance of the `PreTrainedModel` class.
707
709
  * @param {import('./configs.js').PretrainedConfig} config The model configuration.
708
710
  * @param {Record<string, any>} sessions The inference sessions for the model.
711
+ * @param {Record<string, Object>} configs Additional configuration files (e.g., generation_config.json).
709
712
  */
710
- constructor(config, sessions) {
713
+ constructor(config, sessions, configs) {
711
714
  super();
712
715
 
713
716
  this.config = config;
714
717
  this.sessions = sessions;
718
+ this.configs = configs;
715
719
 
716
720
  const modelName = MODEL_CLASS_TO_NAME_MAPPING.get(this.constructor);
717
721
  const modelType = MODEL_TYPE_MAPPING.get(modelName);
@@ -827,7 +831,9 @@ export class PreTrainedModel extends Callable {
827
831
  constructSessions(pretrained_model_name_or_path, {
828
832
  model: options.model_file_name ?? 'model',
829
833
  }, options),
830
- getModelJSON(pretrained_model_name_or_path, 'generation_config.json', false, options),
834
+ getOptionalConfigs(pretrained_model_name_or_path, {
835
+ generation_config: 'generation_config.json',
836
+ }, options),
831
837
  ]);
832
838
 
833
839
  } else if (modelType === MODEL_TYPES.Seq2Seq || modelType === MODEL_TYPES.Vision2Seq) {
@@ -836,7 +842,9 @@ export class PreTrainedModel extends Callable {
836
842
  model: 'encoder_model',
837
843
  decoder_model_merged: 'decoder_model_merged',
838
844
  }, options),
839
- getModelJSON(pretrained_model_name_or_path, 'generation_config.json', false, options),
845
+ getOptionalConfigs(pretrained_model_name_or_path, {
846
+ generation_config: 'generation_config.json',
847
+ }, options),
840
848
  ]);
841
849
 
842
850
  } else if (modelType === MODEL_TYPES.MaskGeneration) {
@@ -866,7 +874,9 @@ export class PreTrainedModel extends Callable {
866
874
  }
867
875
  info = await Promise.all([
868
876
  constructSessions(pretrained_model_name_or_path, sessions, options),
869
- getModelJSON(pretrained_model_name_or_path, 'generation_config.json', false, options),
877
+ getOptionalConfigs(pretrained_model_name_or_path, {
878
+ generation_config: 'generation_config.json',
879
+ }, options),
870
880
  ]);
871
881
 
872
882
  } else if (modelType === MODEL_TYPES.Musicgen) {
@@ -876,7 +886,9 @@ export class PreTrainedModel extends Callable {
876
886
  decoder_model_merged: 'decoder_model_merged',
877
887
  encodec_decode: 'encodec_decode',
878
888
  }, options),
879
- getModelJSON(pretrained_model_name_or_path, 'generation_config.json', false, options),
889
+ getOptionalConfigs(pretrained_model_name_or_path, {
890
+ generation_config: 'generation_config.json',
891
+ }, options),
880
892
  ]);
881
893
 
882
894
  } else { // should be MODEL_TYPES.EncoderOnly
@@ -914,6 +926,14 @@ export class PreTrainedModel extends Callable {
914
926
  return await this._forward(this, model_inputs);
915
927
  }
916
928
 
929
+ /**
930
+ * Get the model's generation config, if it exists.
931
+ * @returns {GenerationConfig|null} The model's generation config if it exists, otherwise `null`.
932
+ */
933
+ get generation_config() {
934
+ return this.configs?.generation_config ?? null;
935
+ }
936
+
917
937
  /**
918
938
  * This function returns a [`LogitsProcessorList`] list object that contains all relevant [`LogitsWarper`]
919
939
  * instances used for multinomial sampling.
@@ -1093,9 +1113,7 @@ export class PreTrainedModel extends Callable {
1093
1113
  const gen_config = new cls(config);
1094
1114
 
1095
1115
  // Apply model's generation config, if it exists
1096
- if ('generation_config' in this) {
1097
- Object.assign(gen_config, this.generation_config);
1098
- }
1116
+ Object.assign(gen_config, this.generation_config ?? {});
1099
1117
 
1100
1118
  // Next, use any generation config specified by the user
1101
1119
  // when calling `generate`
@@ -1455,13 +1473,12 @@ export class PreTrainedModel extends Callable {
1455
1473
  // - GenerationMode.BEAM_SEARCH
1456
1474
  // - GenerationMode.BEAM_SAMPLE
1457
1475
  ////////////////////////////////////////////////////
1458
- let past_key_values = null;
1476
+ let outputs;
1459
1477
  let attentions = {};
1460
1478
  while (true) {
1461
1479
  // prepare model inputs
1462
1480
  model_inputs = this.prepare_inputs_for_generation(all_input_ids, model_inputs, generation_config);
1463
-
1464
- const outputs = await this.forward(model_inputs);
1481
+ outputs = await this.forward(model_inputs);
1465
1482
 
1466
1483
  if (generation_config.output_attentions && generation_config.return_dict_in_generate) {
1467
1484
  // Get attentions if they are present
@@ -1508,10 +1525,6 @@ export class PreTrainedModel extends Callable {
1508
1525
 
1509
1526
  const stop = prepared_stopping_criteria(all_input_ids);
1510
1527
  if (stop.every(x => x)) {
1511
- if (generation_config.return_dict_in_generate) {
1512
- // Get past key values without disposing buffers
1513
- past_key_values = this.getPastKeyValues(outputs, model_inputs.past_key_values, false);
1514
- }
1515
1528
  break;
1516
1529
  }
1517
1530
 
@@ -1524,6 +1537,9 @@ export class PreTrainedModel extends Callable {
1524
1537
  streamer.end();
1525
1538
  }
1526
1539
 
1540
+ // Retrieve and dispose all final past key values (including encoder attentions)
1541
+ const past_key_values = this.getPastKeyValues(outputs, model_inputs.past_key_values, true);
1542
+
1527
1543
  // TODO: ensure all_input_ids is padded correctly...
1528
1544
  const sequences = new Tensor('int64', all_input_ids.flat(), [all_input_ids.length, all_input_ids[0].length]);
1529
1545
 
@@ -1537,6 +1553,12 @@ export class PreTrainedModel extends Callable {
1537
1553
  // logits,
1538
1554
  }
1539
1555
  } else {
1556
+ // Dispose all remaining tensors
1557
+ for (const tensor of Object.values(outputs)) {
1558
+ if (tensor.location === 'gpu-buffer') {
1559
+ tensor.dispose();
1560
+ }
1561
+ }
1540
1562
  return sequences;
1541
1563
  }
1542
1564
  }
@@ -1546,31 +1568,32 @@ export class PreTrainedModel extends Callable {
1546
1568
  *
1547
1569
  * @param {Object} decoderResults The decoder results object.
1548
1570
  * @param {Object} pastKeyValues The previous past key values.
1549
- * @param {boolean} [dispose=true] Whether to dispose of the old gpu buffer.
1550
1571
  * @returns {Object} An object containing past key values.
1551
1572
  */
1552
- getPastKeyValues(decoderResults, pastKeyValues, dispose = true) {
1573
+ getPastKeyValues(decoderResults, pastKeyValues, disposeEncoderPKVs = false) {
1553
1574
  const pkvs = Object.create(null);
1554
1575
 
1555
1576
  for (const name in decoderResults) {
1556
1577
  if (name.startsWith('present')) {
1557
1578
  const newName = name.replace('present', 'past_key_values');
1558
-
1559
- if (pastKeyValues && name.includes('encoder')) {
1560
- // Optimization introduced by optimum to reuse past key values. So, we just replace the constant
1561
- // outputs with the previous past key values.
1579
+ const is_encoder_pkv = name.includes('encoder');
1580
+ if (is_encoder_pkv && pastKeyValues) {
1581
+ // Optimization introduced by optimum to reuse past key values.
1582
+ // So, we just replace the constant outputs (`decoderResults[name]`) with the previous past key values.
1562
1583
  // https://github.com/huggingface/optimum/blob/0bf2c05fb7e1182b52d21b703cfc95fd9e4ea3dc/optimum/onnxruntime/base.py#L677-L704
1563
1584
  pkvs[newName] = pastKeyValues[newName];
1564
- } else {
1565
- if (dispose && pastKeyValues) {
1566
- // Free old gpu buffer
1567
- const t = pastKeyValues[newName];
1568
- if (t.location === 'gpu-buffer') {
1569
- t.dispose();
1570
- }
1571
- }
1585
+ } else { // decoder or using first encoder PKVs
1572
1586
  pkvs[newName] = decoderResults[name];
1573
1587
  }
1588
+
1589
+ if (pastKeyValues && (!is_encoder_pkv || disposeEncoderPKVs)) {
1590
+ // - Always dispose decoder PKVs
1591
+ // - Only dispose encoder past key values when requested (after generation)
1592
+ const t = pastKeyValues[newName];
1593
+ if (t.location === 'gpu-buffer') {
1594
+ t.dispose();
1595
+ }
1596
+ }
1574
1597
  }
1575
1598
  }
1576
1599
  return pkvs;
@@ -2503,17 +2526,6 @@ export class T5PreTrainedModel extends PreTrainedModel {
2503
2526
  'decoder_attention_mask',
2504
2527
  'past_key_values',
2505
2528
  ];
2506
-
2507
- /**
2508
- * Creates a new instance of the `T5PreTrainedModel` class.
2509
- * @param {Object} config The model configuration.
2510
- * @param {Record<string, any>} sessions The inference sessions for the model.
2511
- * @param {GenerationConfig} generation_config The generation configuration.
2512
- */
2513
- constructor(config, sessions, generation_config) {
2514
- super(config, sessions);
2515
- this.generation_config = generation_config;
2516
- }
2517
2529
  };
2518
2530
 
2519
2531
  export class T5Model extends T5PreTrainedModel { }
@@ -2530,18 +2542,7 @@ export class T5ForConditionalGeneration extends T5PreTrainedModel { }
2530
2542
  /**
2531
2543
  * An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models.
2532
2544
  */
2533
- export class LongT5PreTrainedModel extends PreTrainedModel {
2534
- /**
2535
- * Creates a new instance of the `LongT5ForConditionalGeneration` class.
2536
- * @param {Object} config The model configuration.
2537
- * @param {Record<string, any>} sessions The inference sessions for the model.
2538
- * @param {GenerationConfig} generation_config The generation configuration.
2539
- */
2540
- constructor(config, sessions, generation_config) {
2541
- super(config, sessions);
2542
- this.generation_config = generation_config;
2543
- }
2544
- };
2545
+ export class LongT5PreTrainedModel extends PreTrainedModel { };
2545
2546
 
2546
2547
  /**
2547
2548
  * The bare LONGT5 Model transformer outputting raw hidden-states without any specific head on top.
@@ -2557,19 +2558,7 @@ export class LongT5ForConditionalGeneration extends LongT5PreTrainedModel { }
2557
2558
 
2558
2559
  //////////////////////////////////////////////////
2559
2560
  // MT5 models
2560
- export class MT5PreTrainedModel extends PreTrainedModel {
2561
-
2562
- /**
2563
- * Creates a new instance of the `MT5ForConditionalGeneration` class.
2564
- * @param {Object} config The model configuration.
2565
- * @param {Record<string, any>} sessions The inference sessions for the model.
2566
- * @param {GenerationConfig} generation_config The generation configuration.
2567
- */
2568
- constructor(config, sessions, generation_config) {
2569
- super(config, sessions);
2570
- this.generation_config = generation_config;
2571
- }
2572
- };
2561
+ export class MT5PreTrainedModel extends PreTrainedModel { };
2573
2562
 
2574
2563
  export class MT5Model extends MT5PreTrainedModel { }
2575
2564
 
@@ -2581,19 +2570,7 @@ export class MT5ForConditionalGeneration extends MT5PreTrainedModel { }
2581
2570
 
2582
2571
  //////////////////////////////////////////////////
2583
2572
  // Bart models
2584
- export class BartPretrainedModel extends PreTrainedModel {
2585
-
2586
- /**
2587
- * Creates a new instance of the `BartForConditionalGeneration` class.
2588
- * @param {Object} config The model configuration.
2589
- * @param {Record<string, any>} sessions The inference sessions for the model.
2590
- * @param {GenerationConfig} generation_config The generation configuration.
2591
- */
2592
- constructor(config, sessions, generation_config) {
2593
- super(config, sessions);
2594
- this.generation_config = generation_config;
2595
- }
2596
- };
2573
+ export class BartPretrainedModel extends PreTrainedModel { };
2597
2574
 
2598
2575
  /**
2599
2576
  * The bare BART Model outputting raw hidden-states without any specific head on top.
@@ -2624,19 +2601,7 @@ export class BartForSequenceClassification extends BartPretrainedModel {
2624
2601
 
2625
2602
  //////////////////////////////////////////////////
2626
2603
  // MBart models
2627
- export class MBartPreTrainedModel extends PreTrainedModel {
2628
-
2629
- /**
2630
- * Creates a new instance of the `MBartForConditionalGeneration` class.
2631
- * @param {Object} config The model configuration.
2632
- * @param {Record<string, any>} sessions The inference sessions for the model.
2633
- * @param {GenerationConfig} generation_config The generation configuration.
2634
- */
2635
- constructor(config, sessions, generation_config) {
2636
- super(config, sessions);
2637
- this.generation_config = generation_config;
2638
- }
2639
- };
2604
+ export class MBartPreTrainedModel extends PreTrainedModel { };
2640
2605
 
2641
2606
  /**
2642
2607
  * The bare MBART Model outputting raw hidden-states without any specific head on top.
@@ -2670,19 +2635,7 @@ export class MBartForCausalLM extends MBartPreTrainedModel { }
2670
2635
 
2671
2636
  //////////////////////////////////////////////////
2672
2637
  // Blenderbot models
2673
- export class BlenderbotPreTrainedModel extends PreTrainedModel {
2674
-
2675
- /**
2676
- * Creates a new instance of the `BlenderbotForConditionalGeneration` class.
2677
- * @param {Object} config The model configuration.
2678
- * @param {Record<string, any>} sessions The inference sessions for the model.
2679
- * @param {GenerationConfig} generation_config The generation configuration.
2680
- */
2681
- constructor(config, sessions, generation_config) {
2682
- super(config, sessions);
2683
- this.generation_config = generation_config;
2684
- }
2685
- };
2638
+ export class BlenderbotPreTrainedModel extends PreTrainedModel { };
2686
2639
 
2687
2640
  /**
2688
2641
  * The bare Blenderbot Model outputting raw hidden-states without any specific head on top.
@@ -2698,19 +2651,7 @@ export class BlenderbotForConditionalGeneration extends BlenderbotPreTrainedMode
2698
2651
 
2699
2652
  //////////////////////////////////////////////////
2700
2653
  // Blenderbot models
2701
- export class BlenderbotSmallPreTrainedModel extends PreTrainedModel {
2702
-
2703
- /**
2704
- * Creates a new instance of the `BlenderbotForConditionalGeneration` class.
2705
- * @param {Object} config The model configuration.
2706
- * @param {Record<string, any>} sessions The inference sessions for the model.
2707
- * @param {GenerationConfig} generation_config The generation configuration.
2708
- */
2709
- constructor(config, sessions, generation_config) {
2710
- super(config, sessions);
2711
- this.generation_config = generation_config;
2712
- }
2713
- };
2654
+ export class BlenderbotSmallPreTrainedModel extends PreTrainedModel { };
2714
2655
 
2715
2656
  /**
2716
2657
  * The bare BlenderbotSmall Model outputting raw hidden-states without any specific head on top.
@@ -2959,17 +2900,6 @@ export class WhisperPreTrainedModel extends PreTrainedModel {
2959
2900
  'decoder_attention_mask',
2960
2901
  'past_key_values',
2961
2902
  ];
2962
-
2963
- /**
2964
- * Creates a new instance of the `WhisperPreTrainedModel` class.
2965
- * @param {Object} config The model configuration.
2966
- * @param {Record<string, any>} sessions The inference sessions for the model.
2967
- * @param {GenerationConfig} generation_config The generation configuration.
2968
- */
2969
- constructor(config, sessions, generation_config) {
2970
- super(config, sessions);
2971
- this.generation_config = generation_config;
2972
- }
2973
2903
  };
2974
2904
 
2975
2905
  /**
@@ -3240,16 +3170,6 @@ export class VisionEncoderDecoderModel extends PreTrainedModel {
3240
3170
  'encoder_hidden_states',
3241
3171
  'past_key_values',
3242
3172
  ];
3243
- /**
3244
- * Creates a new instance of the `VisionEncoderDecoderModel` class.
3245
- * @param {Object} config The model configuration.
3246
- * @param {Record<string, any>} sessions The inference sessions for the model.
3247
- * @param {GenerationConfig} generation_config The generation configuration.
3248
- */
3249
- constructor(config, sessions, generation_config) {
3250
- super(config, sessions);
3251
- this.generation_config = generation_config;
3252
- }
3253
3173
  }
3254
3174
  //////////////////////////////////////////////////
3255
3175
 
@@ -3264,11 +3184,6 @@ export class LlavaPreTrainedModel extends PreTrainedModel {
3264
3184
  'position_ids',
3265
3185
  'past_key_values',
3266
3186
  ];
3267
-
3268
- constructor(config, sessions, generation_config) {
3269
- super(config, sessions);
3270
- this.generation_config = generation_config;
3271
- }
3272
3187
  }
3273
3188
 
3274
3189
  /**
@@ -3355,11 +3270,6 @@ export class Florence2PreTrainedModel extends PreTrainedModel {
3355
3270
  'past_key_values',
3356
3271
  ];
3357
3272
  main_input_name = 'inputs_embeds';
3358
-
3359
- constructor(config, sessions, generation_config) {
3360
- super(config, sessions);
3361
- this.generation_config = generation_config;
3362
- }
3363
3273
  }
3364
3274
 
3365
3275
  export class Florence2ForConditionalGeneration extends Florence2PreTrainedModel {
@@ -3498,6 +3408,18 @@ export class CLIPPreTrainedModel extends PreTrainedModel { }
3498
3408
  */
3499
3409
  export class CLIPModel extends CLIPPreTrainedModel { }
3500
3410
 
3411
+ /**
3412
+ * The text model from CLIP without any head or projection on top.
3413
+ */
3414
+ export class CLIPTextModel extends CLIPPreTrainedModel {
3415
+ /** @type {PreTrainedModel.from_pretrained} */
3416
+ static async from_pretrained(pretrained_model_name_or_path, options = {}) {
3417
+ // Update default model file name if not provided
3418
+ options.model_file_name ??= 'text_model';
3419
+ return super.from_pretrained(pretrained_model_name_or_path, options);
3420
+ }
3421
+ }
3422
+
3501
3423
  /**
3502
3424
  * CLIP Text Model with a projection layer on top (a linear layer on top of the pooled output)
3503
3425
  *
@@ -3525,7 +3447,6 @@ export class CLIPModel extends CLIPPreTrainedModel { }
3525
3447
  * ```
3526
3448
  */
3527
3449
  export class CLIPTextModelWithProjection extends CLIPPreTrainedModel {
3528
-
3529
3450
  /** @type {PreTrainedModel.from_pretrained} */
3530
3451
  static async from_pretrained(pretrained_model_name_or_path, options = {}) {
3531
3452
  // Update default model file name if not provided
@@ -3534,6 +3455,18 @@ export class CLIPTextModelWithProjection extends CLIPPreTrainedModel {
3534
3455
  }
3535
3456
  }
3536
3457
 
3458
+ /**
3459
+ * The vision model from CLIP without any head or projection on top.
3460
+ */
3461
+ export class CLIPVisionModel extends CLIPPreTrainedModel {
3462
+ /** @type {PreTrainedModel.from_pretrained} */
3463
+ static async from_pretrained(pretrained_model_name_or_path, options = {}) {
3464
+ // Update default model file name if not provided
3465
+ options.model_file_name ??= 'vision_model';
3466
+ return super.from_pretrained(pretrained_model_name_or_path, options);
3467
+ }
3468
+ }
3469
+
3537
3470
  /**
3538
3471
  * CLIP Vision Model with a projection layer on top (a linear layer on top of the pooled output)
3539
3472
  *
@@ -3756,18 +3689,7 @@ export class CLIPSegForImageSegmentation extends CLIPSegPreTrainedModel { }
3756
3689
 
3757
3690
  //////////////////////////////////////////////////
3758
3691
  // GPT2 models
3759
- export class GPT2PreTrainedModel extends PreTrainedModel {
3760
- /**
3761
- * Creates a new instance of the `GPT2PreTrainedModel` class.
3762
- * @param {Object} config The model configuration.
3763
- * @param {Record<string, any>} sessions The inference sessions for the model.
3764
- * @param {GenerationConfig} generation_config The generation configuration.
3765
- */
3766
- constructor(config, sessions, generation_config) {
3767
- super(config, sessions);
3768
- this.generation_config = generation_config;
3769
- }
3770
- }
3692
+ export class GPT2PreTrainedModel extends PreTrainedModel { }
3771
3693
 
3772
3694
  export class GPT2Model extends GPT2PreTrainedModel { }
3773
3695
 
@@ -3780,20 +3702,25 @@ export class GPT2LMHeadModel extends GPT2PreTrainedModel { }
3780
3702
  // }
3781
3703
  //////////////////////////////////////////////////
3782
3704
 
3705
+ //////////////////////////////////////////////////
3706
+ // JAIS models
3707
+ export class JAISPreTrainedModel extends PreTrainedModel { }
3708
+
3709
+ /**
3710
+ * The bare JAIS Model transformer outputting raw hidden-states without any specific head on top.
3711
+ */
3712
+ export class JAISModel extends JAISPreTrainedModel { }
3713
+
3714
+ /**
3715
+ * The JAIS Model transformer with a language modeling head on top (linear layer with weights tied to the input embeddings).
3716
+ */
3717
+ export class JAISLMHeadModel extends JAISPreTrainedModel { }
3718
+ //////////////////////////////////////////////////
3719
+
3720
+
3783
3721
  //////////////////////////////////////////////////
3784
3722
  // GPTNeo models
3785
- export class GPTNeoPreTrainedModel extends PreTrainedModel {
3786
- /**
3787
- * Creates a new instance of the `GPTNeoPreTrainedModel` class.
3788
- * @param {Object} config The model configuration.
3789
- * @param {Record<string, any>} sessions The inference sessions for the model.
3790
- * @param {GenerationConfig} generation_config The generation configuration.
3791
- */
3792
- constructor(config, sessions, generation_config) {
3793
- super(config, sessions);
3794
- this.generation_config = generation_config;
3795
- }
3796
- }
3723
+ export class GPTNeoPreTrainedModel extends PreTrainedModel { }
3797
3724
  export class GPTNeoModel extends GPTNeoPreTrainedModel { }
3798
3725
 
3799
3726
  export class GPTNeoForCausalLM extends GPTNeoPreTrainedModel { }
@@ -3801,18 +3728,7 @@ export class GPTNeoForCausalLM extends GPTNeoPreTrainedModel { }
3801
3728
 
3802
3729
  //////////////////////////////////////////////////
3803
3730
  // GPTNeoX models
3804
- export class GPTNeoXPreTrainedModel extends PreTrainedModel {
3805
- /**
3806
- * Creates a new instance of the `GPTNeoXPreTrainedModel` class.
3807
- * @param {Object} config The model configuration.
3808
- * @param {Record<string, any>} sessions The inference sessions for the model.
3809
- * @param {GenerationConfig} generation_config The generation configuration.
3810
- */
3811
- constructor(config, sessions, generation_config) {
3812
- super(config, sessions);
3813
- this.generation_config = generation_config;
3814
- }
3815
- }
3731
+ export class GPTNeoXPreTrainedModel extends PreTrainedModel { }
3816
3732
  export class GPTNeoXModel extends GPTNeoXPreTrainedModel { }
3817
3733
 
3818
3734
  export class GPTNeoXForCausalLM extends GPTNeoXPreTrainedModel { }
@@ -3821,18 +3737,7 @@ export class GPTNeoXForCausalLM extends GPTNeoXPreTrainedModel { }
3821
3737
 
3822
3738
  //////////////////////////////////////////////////
3823
3739
  // GPT-J models
3824
- export class GPTJPreTrainedModel extends PreTrainedModel {
3825
- /**
3826
- * Creates a new instance of the `GPTJPreTrainedModel` class.
3827
- * @param {Object} config The model configuration.
3828
- * @param {Record<string, any>} sessions The inference sessions for the model.
3829
- * @param {GenerationConfig} generation_config The generation configuration.
3830
- */
3831
- constructor(config, sessions, generation_config) {
3832
- super(config, sessions);
3833
- this.generation_config = generation_config;
3834
- }
3835
- }
3740
+ export class GPTJPreTrainedModel extends PreTrainedModel { }
3836
3741
 
3837
3742
  export class GPTJModel extends GPTJPreTrainedModel { }
3838
3743
 
@@ -3842,18 +3747,7 @@ export class GPTJForCausalLM extends GPTJPreTrainedModel { }
3842
3747
 
3843
3748
  //////////////////////////////////////////////////
3844
3749
  // GPTBigCode models
3845
- export class GPTBigCodePreTrainedModel extends PreTrainedModel {
3846
- /**
3847
- * Creates a new instance of the `GPTBigCodePreTrainedModel` class.
3848
- * @param {Object} config The model configuration.
3849
- * @param {Record<string, any>} sessions The inference sessions for the model.
3850
- * @param {GenerationConfig} generation_config The generation configuration.
3851
- */
3852
- constructor(config, sessions, generation_config) {
3853
- super(config, sessions);
3854
- this.generation_config = generation_config;
3855
- }
3856
- }
3750
+ export class GPTBigCodePreTrainedModel extends PreTrainedModel { }
3857
3751
 
3858
3752
  export class GPTBigCodeModel extends GPTBigCodePreTrainedModel { }
3859
3753
 
@@ -3862,18 +3756,7 @@ export class GPTBigCodeForCausalLM extends GPTBigCodePreTrainedModel { }
3862
3756
 
3863
3757
  //////////////////////////////////////////////////
3864
3758
  // CodeGen models
3865
- export class CodeGenPreTrainedModel extends PreTrainedModel {
3866
- /**
3867
- * Creates a new instance of the `CodeGenPreTrainedModel` class.
3868
- * @param {Object} config The model configuration.
3869
- * @param {Record<string, any>} sessions The inference sessions for the model.
3870
- * @param {GenerationConfig} generation_config The generation configuration.
3871
- */
3872
- constructor(config, sessions, generation_config) {
3873
- super(config, sessions);
3874
- this.generation_config = generation_config;
3875
- }
3876
- }
3759
+ export class CodeGenPreTrainedModel extends PreTrainedModel { }
3877
3760
  /**
3878
3761
  * CodeGenModel is a class representing a code generation model without a language model head.
3879
3762
  */
@@ -3892,18 +3775,7 @@ export class CodeGenForCausalLM extends CodeGenPreTrainedModel { }
3892
3775
  /**
3893
3776
  * The bare LLama Model outputting raw hidden-states without any specific head on top.
3894
3777
  */
3895
- export class LlamaPreTrainedModel extends PreTrainedModel {
3896
- /**
3897
- * Creates a new instance of the `LlamaPreTrainedModel` class.
3898
- * @param {Object} config The model configuration.
3899
- * @param {Record<string, any>} sessions The inference sessions for the model.
3900
- * @param {GenerationConfig} generation_config The generation configuration.
3901
- */
3902
- constructor(config, sessions, generation_config) {
3903
- super(config, sessions);
3904
- this.generation_config = generation_config;
3905
- }
3906
- }
3778
+ export class LlamaPreTrainedModel extends PreTrainedModel { }
3907
3779
  /**
3908
3780
  * The bare LLaMA Model outputting raw hidden-states without any specific head on top.
3909
3781
  */
@@ -3912,24 +3784,22 @@ export class LlamaModel extends LlamaPreTrainedModel { }
3912
3784
  export class LlamaForCausalLM extends LlamaPreTrainedModel { }
3913
3785
  //////////////////////////////////////////////////
3914
3786
 
3787
+
3788
+ //////////////////////////////////////////////////
3789
+ // Granite models
3790
+ export class GranitePreTrainedModel extends PreTrainedModel { }
3791
+ export class GraniteModel extends GranitePreTrainedModel { }
3792
+ export class GraniteForCausalLM extends GranitePreTrainedModel { }
3793
+ //////////////////////////////////////////////////
3794
+
3795
+
3915
3796
  //////////////////////////////////////////////////
3916
3797
  // Cohere models
3917
3798
 
3918
3799
  /**
3919
3800
  * The bare Cohere Model outputting raw hidden-states without any specific head on top.
3920
3801
  */
3921
- export class CoherePreTrainedModel extends PreTrainedModel {
3922
- /**
3923
- * Creates a new instance of the `CoherePreTrainedModel` class.
3924
- * @param {Object} config The model configuration.
3925
- * @param {Record<string, any>} sessions The inference sessions for the model.
3926
- * @param {GenerationConfig} generation_config The generation configuration.
3927
- */
3928
- constructor(config, sessions, generation_config) {
3929
- super(config, sessions);
3930
- this.generation_config = generation_config;
3931
- }
3932
- }
3802
+ export class CoherePreTrainedModel extends PreTrainedModel { }
3933
3803
  export class CohereModel extends CoherePreTrainedModel { }
3934
3804
 
3935
3805
  export class CohereForCausalLM extends CoherePreTrainedModel { }
@@ -3941,18 +3811,7 @@ export class CohereForCausalLM extends CoherePreTrainedModel { }
3941
3811
  /**
3942
3812
  * The bare Gemma Model outputting raw hidden-states without any specific head on top.
3943
3813
  */
3944
- export class GemmaPreTrainedModel extends PreTrainedModel {
3945
- /**
3946
- * Creates a new instance of the `GemmaPreTrainedModel` class.
3947
- * @param {Object} config The model configuration.
3948
- * @param {Record<string, any>} sessions The inference sessions for the model.
3949
- * @param {GenerationConfig} generation_config The generation configuration.
3950
- */
3951
- constructor(config, sessions, generation_config) {
3952
- super(config, sessions);
3953
- this.generation_config = generation_config;
3954
- }
3955
- }
3814
+ export class GemmaPreTrainedModel extends PreTrainedModel { }
3956
3815
  /**
3957
3816
  * The bare Gemma Model outputting raw hidden-states without any specific head on top.
3958
3817
  */
@@ -3967,18 +3826,7 @@ export class GemmaForCausalLM extends GemmaPreTrainedModel { }
3967
3826
  /**
3968
3827
  * The bare Gemma2 Model outputting raw hidden-states without any specific head on top.
3969
3828
  */
3970
- export class Gemma2PreTrainedModel extends PreTrainedModel {
3971
- /**
3972
- * Creates a new instance of the `Gemma2PreTrainedModel` class.
3973
- * @param {Object} config The model configuration.
3974
- * @param {Record<string, any>} sessions The inference sessions for the model.
3975
- * @param {GenerationConfig} generation_config The generation configuration.
3976
- */
3977
- constructor(config, sessions, generation_config) {
3978
- super(config, sessions);
3979
- this.generation_config = generation_config;
3980
- }
3981
- }
3829
+ export class Gemma2PreTrainedModel extends PreTrainedModel { }
3982
3830
  /**
3983
3831
  * The bare Gemma2 Model outputting raw hidden-states without any specific head on top.
3984
3832
  */
@@ -3988,18 +3836,7 @@ export class Gemma2ForCausalLM extends Gemma2PreTrainedModel { }
3988
3836
  //////////////////////////////////////////////////
3989
3837
 
3990
3838
  //////////////////////////////////////////////////
3991
- export class OpenELMPreTrainedModel extends PreTrainedModel {
3992
- /**
3993
- * Creates a new instance of the `OpenELMPreTrainedModel` class.
3994
- * @param {Object} config The model configuration.
3995
- * @param {Record<string, any>} sessions The inference sessions for the model.
3996
- * @param {GenerationConfig} generation_config The generation configuration.
3997
- */
3998
- constructor(config, sessions, generation_config) {
3999
- super(config, sessions);
4000
- this.generation_config = generation_config;
4001
- }
4002
- }
3839
+ export class OpenELMPreTrainedModel extends PreTrainedModel { }
4003
3840
  export class OpenELMModel extends OpenELMPreTrainedModel { }
4004
3841
 
4005
3842
  export class OpenELMForCausalLM extends OpenELMPreTrainedModel { }
@@ -4011,18 +3848,7 @@ export class OpenELMForCausalLM extends OpenELMPreTrainedModel { }
4011
3848
  /**
4012
3849
  * The bare Qwen2 Model outputting raw hidden-states without any specific head on top.
4013
3850
  */
4014
- export class Qwen2PreTrainedModel extends PreTrainedModel {
4015
- /**
4016
- * Creates a new instance of the `Qwen2PreTrainedModel` class.
4017
- * @param {Object} config The model configuration.
4018
- * @param {Record<string, any>} sessions The inference sessions for the model.
4019
- * @param {GenerationConfig} generation_config The generation configuration.
4020
- */
4021
- constructor(config, sessions, generation_config) {
4022
- super(config, sessions);
4023
- this.generation_config = generation_config;
4024
- }
4025
- }
3851
+ export class Qwen2PreTrainedModel extends PreTrainedModel { }
4026
3852
  /**
4027
3853
  * The bare Qwen2 Model outputting raw hidden-states without any specific head on top.
4028
3854
  */
@@ -4034,18 +3860,7 @@ export class Qwen2ForCausalLM extends Qwen2PreTrainedModel { }
4034
3860
 
4035
3861
  //////////////////////////////////////////////////
4036
3862
  // Phi models
4037
- export class PhiPreTrainedModel extends PreTrainedModel {
4038
- /**
4039
- * Creates a new instance of the `PhiPreTrainedModel` class.
4040
- * @param {Object} config The model configuration.
4041
- * @param {Record<string, any>} sessions The inference sessions for the model.
4042
- * @param {GenerationConfig} generation_config The generation configuration.
4043
- */
4044
- constructor(config, sessions, generation_config) {
4045
- super(config, sessions);
4046
- this.generation_config = generation_config;
4047
- }
4048
- }
3863
+ export class PhiPreTrainedModel extends PreTrainedModel { }
4049
3864
  /**
4050
3865
  * The bare Phi Model outputting raw hidden-states without any specific head on top.
4051
3866
  */
@@ -4056,18 +3871,7 @@ export class PhiForCausalLM extends PhiPreTrainedModel { }
4056
3871
 
4057
3872
  //////////////////////////////////////////////////
4058
3873
  // Phi3 models
4059
- export class Phi3PreTrainedModel extends PreTrainedModel {
4060
- /**
4061
- * Creates a new instance of the `Phi3PreTrainedModel` class.
4062
- * @param {Object} config The model configuration.
4063
- * @param {Record<string, any>} sessions The inference sessions for the model.
4064
- * @param {GenerationConfig} generation_config The generation configuration.
4065
- */
4066
- constructor(config, sessions, generation_config) {
4067
- super(config, sessions);
4068
- this.generation_config = generation_config;
4069
- }
4070
- }
3874
+ export class Phi3PreTrainedModel extends PreTrainedModel { }
4071
3875
 
4072
3876
  /**
4073
3877
  * The bare Phi3 Model outputting raw hidden-states without any specific head on top.
@@ -4083,18 +3887,7 @@ export class Phi3ForCausalLM extends Phi3PreTrainedModel { }
4083
3887
  /**
4084
3888
  * The Bloom Model transformer with a language modeling head on top (linear layer with weights tied to the input embeddings).
4085
3889
  */
4086
- export class BloomPreTrainedModel extends PreTrainedModel {
4087
- /**
4088
- * Creates a new instance of the `BloomPreTrainedModel` class.
4089
- * @param {Object} config The model configuration.
4090
- * @param {Record<string, any>} sessions The inference sessions for the model.
4091
- * @param {GenerationConfig} generation_config The generation configuration.
4092
- */
4093
- constructor(config, sessions, generation_config) {
4094
- super(config, sessions);
4095
- this.generation_config = generation_config;
4096
- }
4097
- }
3890
+ export class BloomPreTrainedModel extends PreTrainedModel { }
4098
3891
 
4099
3892
  /**
4100
3893
  * The bare Bloom Model transformer outputting raw hidden-states without any specific head on top.
@@ -4109,18 +3902,7 @@ export class BloomForCausalLM extends BloomPreTrainedModel { }
4109
3902
 
4110
3903
  //////////////////////////////////////////////////
4111
3904
  // MPT models
4112
- export class MptPreTrainedModel extends PreTrainedModel {
4113
- /**
4114
- * Creates a new instance of the `MptPreTrainedModel` class.
4115
- * @param {Object} config The model configuration.
4116
- * @param {Record<string, any>} sessions The inference sessions for the model.
4117
- * @param {GenerationConfig} generation_config The generation configuration.
4118
- */
4119
- constructor(config, sessions, generation_config) {
4120
- super(config, sessions);
4121
- this.generation_config = generation_config;
4122
- }
4123
- }
3905
+ export class MptPreTrainedModel extends PreTrainedModel { }
4124
3906
 
4125
3907
  /**
4126
3908
  * The bare Mpt Model transformer outputting raw hidden-states without any specific head on top.
@@ -4136,18 +3918,7 @@ export class MptForCausalLM extends MptPreTrainedModel { }
4136
3918
 
4137
3919
  //////////////////////////////////////////////////
4138
3920
  // OPT models
4139
- export class OPTPreTrainedModel extends PreTrainedModel {
4140
- /**
4141
- * Creates a new instance of the `OPTPreTrainedModel` class.
4142
- * @param {Object} config The model configuration.
4143
- * @param {Record<string, any>} sessions The inference sessions for the model.
4144
- * @param {GenerationConfig} generation_config The generation configuration.
4145
- */
4146
- constructor(config, sessions, generation_config) {
4147
- super(config, sessions);
4148
- this.generation_config = generation_config;
4149
- }
4150
- }
3921
+ export class OPTPreTrainedModel extends PreTrainedModel { }
4151
3922
 
4152
3923
  /**
4153
3924
  * The bare OPT Model outputting raw hidden-states without any specific head on top.
@@ -4173,6 +3944,43 @@ export class ViTForImageClassification extends ViTPreTrainedModel {
4173
3944
  }
4174
3945
  //////////////////////////////////////////////////
4175
3946
 
3947
+ //////////////////////////////////////////////////
3948
+ export class PvtPreTrainedModel extends PreTrainedModel { }
3949
+ export class PvtModel extends PvtPreTrainedModel { }
3950
+ export class PvtForImageClassification extends PvtPreTrainedModel {
3951
+ /**
3952
+ * @param {any} model_inputs
3953
+ */
3954
+ async _call(model_inputs) {
3955
+ return new SequenceClassifierOutput(await super._call(model_inputs));
3956
+ }
3957
+ }
3958
+ //////////////////////////////////////////////////
3959
+
3960
+ //////////////////////////////////////////////////
3961
+ export class ViTMAEPreTrainedModel extends PreTrainedModel { }
3962
+ export class ViTMAEModel extends ViTMAEPreTrainedModel { }
3963
+ //////////////////////////////////////////////////
3964
+
3965
+
3966
+ //////////////////////////////////////////////////
3967
+ export class ViTMSNPreTrainedModel extends PreTrainedModel { }
3968
+ export class ViTMSNModel extends ViTMSNPreTrainedModel { }
3969
+ export class ViTMSNForImageClassification extends ViTMSNPreTrainedModel {
3970
+ /**
3971
+ * @param {any} model_inputs
3972
+ */
3973
+ async _call(model_inputs) {
3974
+ return new SequenceClassifierOutput(await super._call(model_inputs));
3975
+ }
3976
+ }
3977
+ //////////////////////////////////////////////////
3978
+
3979
+ //////////////////////////////////////////////////
3980
+ export class GroupViTPreTrainedModel extends PreTrainedModel { }
3981
+ export class GroupViTModel extends GroupViTPreTrainedModel { }
3982
+ //////////////////////////////////////////////////
3983
+
4176
3984
 
4177
3985
  //////////////////////////////////////////////////
4178
3986
  export class FastViTPreTrainedModel extends PreTrainedModel { }
@@ -4426,6 +4234,19 @@ export class DeiTForImageClassification extends DeiTPreTrainedModel {
4426
4234
  }
4427
4235
  //////////////////////////////////////////////////
4428
4236
 
4237
+ //////////////////////////////////////////////////
4238
+ export class HieraPreTrainedModel extends PreTrainedModel { }
4239
+ export class HieraModel extends HieraPreTrainedModel { }
4240
+ export class HieraForImageClassification extends HieraPreTrainedModel {
4241
+ /**
4242
+ * @param {any} model_inputs
4243
+ */
4244
+ async _call(model_inputs) {
4245
+ return new SequenceClassifierOutput(await super._call(model_inputs));
4246
+ }
4247
+ }
4248
+ //////////////////////////////////////////////////
4249
+
4429
4250
 
4430
4251
  //////////////////////////////////////////////////
4431
4252
  /**
@@ -4565,6 +4386,24 @@ export class DepthAnythingForDepthEstimation extends DepthAnythingPreTrainedMode
4565
4386
  //////////////////////////////////////////////////
4566
4387
 
4567
4388
 
4389
+ //////////////////////////////////////////////////
4390
+ export class SapiensPreTrainedModel extends PreTrainedModel { }
4391
+ export class SapiensForSemanticSegmentation extends SapiensPreTrainedModel { }
4392
+ export class SapiensForDepthEstimation extends SapiensPreTrainedModel { }
4393
+ export class SapiensForNormalEstimation extends SapiensPreTrainedModel { }
4394
+ //////////////////////////////////////////////////
4395
+
4396
+ //////////////////////////////////////////////////
4397
+ export class DepthProPreTrainedModel extends PreTrainedModel { }
4398
+ export class DepthProForDepthEstimation extends DepthProPreTrainedModel { }
4399
+ //////////////////////////////////////////////////
4400
+
4401
+ //////////////////////////////////////////////////
4402
+ export class MaskFormerPreTrainedModel extends PreTrainedModel { }
4403
+ export class MaskFormerModel extends MaskFormerPreTrainedModel { }
4404
+ export class MaskFormerForInstanceSegmentation extends MaskFormerPreTrainedModel { }
4405
+ //////////////////////////////////////////////////
4406
+
4568
4407
  //////////////////////////////////////////////////
4569
4408
  export class GLPNPreTrainedModel extends PreTrainedModel { }
4570
4409
 
@@ -4941,19 +4780,7 @@ export class SamImageSegmentationOutput extends ModelOutput {
4941
4780
 
4942
4781
  //////////////////////////////////////////////////
4943
4782
  // MarianMT models
4944
- export class MarianPreTrainedModel extends PreTrainedModel {
4945
-
4946
- /**
4947
- * Creates a new instance of the `MarianMTModel` class.
4948
- * @param {Object} config The model configuration.
4949
- * @param {Record<string, any>} sessions The inference sessions for the model.
4950
- * @param {GenerationConfig} generation_config The generation configuration.
4951
- */
4952
- constructor(config, sessions, generation_config) {
4953
- super(config, sessions);
4954
- this.generation_config = generation_config;
4955
- }
4956
- };
4783
+ export class MarianPreTrainedModel extends PreTrainedModel { };
4957
4784
 
4958
4785
  export class MarianModel extends MarianPreTrainedModel { }
4959
4786
 
@@ -4962,19 +4789,7 @@ export class MarianMTModel extends MarianPreTrainedModel { }
4962
4789
 
4963
4790
  //////////////////////////////////////////////////
4964
4791
  // M2M100 models
4965
- export class M2M100PreTrainedModel extends PreTrainedModel {
4966
-
4967
- /**
4968
- * Creates a new instance of the `M2M100ForConditionalGeneration` class.
4969
- * @param {Object} config The model configuration.
4970
- * @param {Record<string, any>} sessions The inference sessions for the model.
4971
- * @param {GenerationConfig} generation_config The generation configuration.
4972
- */
4973
- constructor(config, sessions, generation_config) {
4974
- super(config, sessions);
4975
- this.generation_config = generation_config;
4976
- }
4977
- };
4792
+ export class M2M100PreTrainedModel extends PreTrainedModel { };
4978
4793
 
4979
4794
  export class M2M100Model extends M2M100PreTrainedModel { }
4980
4795
 
@@ -5484,19 +5299,7 @@ export class WavLMForAudioFrameClassification extends WavLMPreTrainedModel {
5484
5299
  /**
5485
5300
  * An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models.
5486
5301
  */
5487
- export class SpeechT5PreTrainedModel extends PreTrainedModel {
5488
-
5489
- /**
5490
- * Creates a new instance of the `SpeechT5ForTextToSpeech` class.
5491
- * @param {Object} config The model configuration.
5492
- * @param {Record<string, any>} sessions The inference sessions for the model.
5493
- * @param {GenerationConfig} generation_config The generation configuration.
5494
- */
5495
- constructor(config, sessions, generation_config) {
5496
- super(config, sessions);
5497
- this.generation_config = generation_config;
5498
- }
5499
- };
5302
+ export class SpeechT5PreTrainedModel extends PreTrainedModel { };
5500
5303
 
5501
5304
  /**
5502
5305
  * The bare SpeechT5 Encoder-Decoder Model outputting raw hidden-states without any specific pre- or post-nets.
@@ -5657,18 +5460,7 @@ export class SpeechT5HifiGan extends PreTrainedModel {
5657
5460
 
5658
5461
  //////////////////////////////////////////////////
5659
5462
  // TrOCR models
5660
- export class TrOCRPreTrainedModel extends PreTrainedModel {
5661
- /**
5662
- * Creates a new instance of the `TrOCRPreTrainedModel` class.
5663
- * @param {Object} config The configuration of the model.
5664
- * @param {any} session The ONNX session containing the model weights.
5665
- * @param {GenerationConfig} generation_config The generation configuration.
5666
- */
5667
- constructor(config, session, generation_config) {
5668
- super(config, session);
5669
- this.generation_config = generation_config;
5670
- }
5671
- }
5463
+ export class TrOCRPreTrainedModel extends PreTrainedModel { }
5672
5464
 
5673
5465
  /**
5674
5466
  * The TrOCR Decoder with a language modeling head.
@@ -5683,18 +5475,7 @@ export class TrOCRForCausalLM extends TrOCRPreTrainedModel { }
5683
5475
  /**
5684
5476
  * The bare Mistral Model outputting raw hidden-states without any specific head on top.
5685
5477
  */
5686
- export class MistralPreTrainedModel extends PreTrainedModel {
5687
- /**
5688
- * Creates a new instance of the `MistralPreTrainedModel` class.
5689
- * @param {Object} config The configuration of the model.
5690
- * @param {any} session The ONNX session containing the model weights.
5691
- * @param {GenerationConfig} generation_config The generation configuration.
5692
- */
5693
- constructor(config, session, generation_config) {
5694
- super(config, session);
5695
- this.generation_config = generation_config;
5696
- }
5697
- }
5478
+ export class MistralPreTrainedModel extends PreTrainedModel { }
5698
5479
 
5699
5480
  export class MistralModel extends MistralPreTrainedModel { }
5700
5481
 
@@ -5707,18 +5488,7 @@ export class MistralForCausalLM extends MistralPreTrainedModel { }
5707
5488
  /**
5708
5489
  * The bare Starcoder2 Model outputting raw hidden-states without any specific head on top.
5709
5490
  */
5710
- export class Starcoder2PreTrainedModel extends PreTrainedModel {
5711
- /**
5712
- * Creates a new instance of the `Starcoder2PreTrainedModel` class.
5713
- * @param {Object} config The configuration of the model.
5714
- * @param {any} session The ONNX session containing the model weights.
5715
- * @param {GenerationConfig} generation_config The generation configuration.
5716
- */
5717
- constructor(config, session, generation_config) {
5718
- super(config, session);
5719
- this.generation_config = generation_config;
5720
- }
5721
- }
5491
+ export class Starcoder2PreTrainedModel extends PreTrainedModel { }
5722
5492
 
5723
5493
  export class Starcoder2Model extends Starcoder2PreTrainedModel { }
5724
5494
 
@@ -5731,18 +5501,7 @@ export class Starcoder2ForCausalLM extends Starcoder2PreTrainedModel { }
5731
5501
  /**
5732
5502
  * The bare Falcon Model outputting raw hidden-states without any specific head on top.
5733
5503
  */
5734
- export class FalconPreTrainedModel extends PreTrainedModel {
5735
- /**
5736
- * Creates a new instance of the `FalconPreTrainedModel` class.
5737
- * @param {Object} config The configuration of the model.
5738
- * @param {any} session The ONNX session containing the model weights.
5739
- * @param {GenerationConfig} generation_config The generation configuration.
5740
- */
5741
- constructor(config, session, generation_config) {
5742
- super(config, session);
5743
- this.generation_config = generation_config;
5744
- }
5745
- }
5504
+ export class FalconPreTrainedModel extends PreTrainedModel { }
5746
5505
 
5747
5506
  export class FalconModel extends FalconPreTrainedModel { }
5748
5507
 
@@ -5892,18 +5651,7 @@ export class SegformerForSemanticSegmentation extends SegformerPreTrainedModel {
5892
5651
 
5893
5652
  //////////////////////////////////////////////////
5894
5653
  // StableLm models
5895
- export class StableLmPreTrainedModel extends PreTrainedModel {
5896
- /**
5897
- * Creates a new instance of the `StableLmPreTrainedModel` class.
5898
- * @param {Object} config The configuration of the model.
5899
- * @param {any} session The ONNX session containing the model weights.
5900
- * @param {GenerationConfig} generation_config The generation configuration.
5901
- */
5902
- constructor(config, session, generation_config) {
5903
- super(config, session);
5904
- this.generation_config = generation_config;
5905
- }
5906
- }
5654
+ export class StableLmPreTrainedModel extends PreTrainedModel { }
5907
5655
 
5908
5656
  /**
5909
5657
  * The bare StableLm Model transformer outputting raw hidden-states without any specific head on top.
@@ -5997,17 +5745,6 @@ export class MusicgenForConditionalGeneration extends PreTrainedModel { // NOTE:
5997
5745
  'past_key_values',
5998
5746
  ];
5999
5747
 
6000
- /**
6001
- * Creates a new instance of the `MusicgenForConditionalGeneration` class.
6002
- * @param {Object} config The model configuration.
6003
- * @param {Record<string, any>} sessions The inference sessions for the model.
6004
- * @param {GenerationConfig} generation_config The generation configuration.
6005
- */
6006
- constructor(config, sessions, generation_config) {
6007
- super(config, sessions);
6008
- this.generation_config = generation_config;
6009
- }
6010
-
6011
5748
  /**
6012
5749
  * Apply the pattern mask to the final ids,
6013
5750
  * then revert the pattern delay mask by filtering the pad token id in a single step.
@@ -6086,6 +5823,7 @@ export class MusicgenForConditionalGeneration extends PreTrainedModel { // NOTE:
6086
5823
  return audio_values;
6087
5824
  }
6088
5825
  }
5826
+ //////////////////////////////////////////////////
6089
5827
 
6090
5828
  //////////////////////////////////////////////////
6091
5829
  // MobileNetV1 models
@@ -6179,6 +5917,17 @@ export class MobileNetV4ForImageClassification extends MobileNetV4PreTrainedMode
6179
5917
  }
6180
5918
  //////////////////////////////////////////////////
6181
5919
 
5920
+ //////////////////////////////////////////////////
5921
+ // Decision Transformer models
5922
+ export class DecisionTransformerPreTrainedModel extends PreTrainedModel { }
5923
+
5924
+ /**
5925
+ * The model builds upon the GPT2 architecture to perform autoregressive prediction of actions in an offline RL setting.
5926
+ * Refer to the paper for more details: https://arxiv.org/abs/2106.01345
5927
+ */
5928
+ export class DecisionTransformerModel extends DecisionTransformerPreTrainedModel { }
5929
+
5930
+ //////////////////////////////////////////////////
6182
5931
 
6183
5932
  //////////////////////////////////////////////////
6184
5933
  // AutoModels, used to simplify construction of PreTrainedModels
@@ -6217,7 +5966,7 @@ export class PretrainedMixin {
6217
5966
  session_options = {},
6218
5967
  } = {}) {
6219
5968
 
6220
- let options = {
5969
+ const options = {
6221
5970
  progress_callback,
6222
5971
  config,
6223
5972
  cache_dir,
@@ -6236,7 +5985,7 @@ export class PretrainedMixin {
6236
5985
  throw new Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: " + this.name);
6237
5986
  }
6238
5987
 
6239
- for (let MODEL_CLASS_MAPPING of this.MODEL_CLASS_MAPPINGS) {
5988
+ for (const MODEL_CLASS_MAPPING of this.MODEL_CLASS_MAPPINGS) {
6240
5989
  const modelInfo = MODEL_CLASS_MAPPING.get(options.config.model_type);
6241
5990
  if (!modelInfo) {
6242
5991
  continue; // Item not found in this mapping
@@ -6291,6 +6040,10 @@ const MODEL_MAPPING_NAMES_ENCODER_ONLY = new Map([
6291
6040
  ['rt_detr', ['RTDetrModel', RTDetrModel]],
6292
6041
  ['table-transformer', ['TableTransformerModel', TableTransformerModel]],
6293
6042
  ['vit', ['ViTModel', ViTModel]],
6043
+ ['pvt', ['PvtModel', PvtModel]],
6044
+ ['vit_msn', ['ViTMSNModel', ViTMSNModel]],
6045
+ ['vit_mae', ['ViTMAEModel', ViTMAEModel]],
6046
+ ['groupvit', ['GroupViTModel', GroupViTModel]],
6294
6047
  ['fastvit', ['FastViTModel', FastViTModel]],
6295
6048
  ['mobilevit', ['MobileViTModel', MobileViTModel]],
6296
6049
  ['mobilevitv2', ['MobileViTV2Model', MobileViTV2Model]],
@@ -6298,6 +6051,7 @@ const MODEL_MAPPING_NAMES_ENCODER_ONLY = new Map([
6298
6051
  ['owlv2', ['Owlv2Model', Owlv2Model]],
6299
6052
  ['beit', ['BeitModel', BeitModel]],
6300
6053
  ['deit', ['DeiTModel', DeiTModel]],
6054
+ ['hiera', ['HieraModel', HieraModel]],
6301
6055
  ['convnext', ['ConvNextModel', ConvNextModel]],
6302
6056
  ['convnextv2', ['ConvNextV2Model', ConvNextV2Model]],
6303
6057
  ['dinov2', ['Dinov2Model', Dinov2Model]],
@@ -6312,10 +6066,14 @@ const MODEL_MAPPING_NAMES_ENCODER_ONLY = new Map([
6312
6066
  ['hifigan', ['SpeechT5HifiGan', SpeechT5HifiGan]],
6313
6067
  ['efficientnet', ['EfficientNetModel', EfficientNetModel]],
6314
6068
 
6069
+ ['decision_transformer', ['DecisionTransformerModel', DecisionTransformerModel]],
6070
+
6315
6071
  ['mobilenet_v1', ['MobileNetV1Model', MobileNetV1Model]],
6316
6072
  ['mobilenet_v2', ['MobileNetV2Model', MobileNetV2Model]],
6317
6073
  ['mobilenet_v3', ['MobileNetV3Model', MobileNetV3Model]],
6318
6074
  ['mobilenet_v4', ['MobileNetV4Model', MobileNetV4Model]],
6075
+
6076
+ ['maskformer', ['MaskFormerModel', MaskFormerModel]],
6319
6077
  ]);
6320
6078
 
6321
6079
  const MODEL_MAPPING_NAMES_ENCODER_DECODER = new Map([
@@ -6334,6 +6092,7 @@ const MODEL_MAPPING_NAMES_ENCODER_DECODER = new Map([
6334
6092
 
6335
6093
  const MODEL_MAPPING_NAMES_DECODER_ONLY = new Map([
6336
6094
  ['bloom', ['BloomModel', BloomModel]],
6095
+ ['jais', ['JAISModel', JAISModel]],
6337
6096
  ['gpt2', ['GPT2Model', GPT2Model]],
6338
6097
  ['gptj', ['GPTJModel', GPTJModel]],
6339
6098
  ['gpt_bigcode', ['GPTBigCodeModel', GPTBigCodeModel]],
@@ -6341,6 +6100,7 @@ const MODEL_MAPPING_NAMES_DECODER_ONLY = new Map([
6341
6100
  ['gpt_neox', ['GPTNeoXModel', GPTNeoXModel]],
6342
6101
  ['codegen', ['CodeGenModel', CodeGenModel]],
6343
6102
  ['llama', ['LlamaModel', LlamaModel]],
6103
+ ['granite', ['GraniteModel', GraniteModel]],
6344
6104
  ['cohere', ['CohereModel', CohereModel]],
6345
6105
  ['gemma', ['GemmaModel', GemmaModel]],
6346
6106
  ['gemma2', ['Gemma2Model', Gemma2Model]],
@@ -6422,12 +6182,14 @@ const MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES = new Map([
6422
6182
  const MODEL_FOR_CAUSAL_LM_MAPPING_NAMES = new Map([
6423
6183
  ['bloom', ['BloomForCausalLM', BloomForCausalLM]],
6424
6184
  ['gpt2', ['GPT2LMHeadModel', GPT2LMHeadModel]],
6185
+ ['jais', ['JAISLMHeadModel', JAISLMHeadModel]],
6425
6186
  ['gptj', ['GPTJForCausalLM', GPTJForCausalLM]],
6426
6187
  ['gpt_bigcode', ['GPTBigCodeForCausalLM', GPTBigCodeForCausalLM]],
6427
6188
  ['gpt_neo', ['GPTNeoForCausalLM', GPTNeoForCausalLM]],
6428
6189
  ['gpt_neox', ['GPTNeoXForCausalLM', GPTNeoXForCausalLM]],
6429
6190
  ['codegen', ['CodeGenForCausalLM', CodeGenForCausalLM]],
6430
6191
  ['llama', ['LlamaForCausalLM', LlamaForCausalLM]],
6192
+ ['granite', ['GraniteForCausalLM', GraniteForCausalLM]],
6431
6193
  ['cohere', ['CohereForCausalLM', CohereForCausalLM]],
6432
6194
  ['gemma', ['GemmaForCausalLM', GemmaForCausalLM]],
6433
6195
  ['gemma2', ['Gemma2ForCausalLM', Gemma2ForCausalLM]],
@@ -6498,11 +6260,14 @@ const MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES = new Map([
6498
6260
 
6499
6261
  const MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES = new Map([
6500
6262
  ['vit', ['ViTForImageClassification', ViTForImageClassification]],
6263
+ ['pvt', ['PvtForImageClassification', PvtForImageClassification]],
6264
+ ['vit_msn', ['ViTMSNForImageClassification', ViTMSNForImageClassification]],
6501
6265
  ['fastvit', ['FastViTForImageClassification', FastViTForImageClassification]],
6502
6266
  ['mobilevit', ['MobileViTForImageClassification', MobileViTForImageClassification]],
6503
6267
  ['mobilevitv2', ['MobileViTV2ForImageClassification', MobileViTV2ForImageClassification]],
6504
6268
  ['beit', ['BeitForImageClassification', BeitForImageClassification]],
6505
6269
  ['deit', ['DeiTForImageClassification', DeiTForImageClassification]],
6270
+ ['hiera', ['HieraForImageClassification', HieraForImageClassification]],
6506
6271
  ['convnext', ['ConvNextForImageClassification', ConvNextForImageClassification]],
6507
6272
  ['convnextv2', ['ConvNextV2ForImageClassification', ConvNextV2ForImageClassification]],
6508
6273
  ['dinov2', ['Dinov2ForImageClassification', Dinov2ForImageClassification]],
@@ -6529,12 +6294,19 @@ const MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES = new Map([
6529
6294
  ]);
6530
6295
 
6531
6296
  const MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES = new Map([
6297
+ // TODO: Do not add new models here
6532
6298
  ['detr', ['DetrForSegmentation', DetrForSegmentation]],
6533
6299
  ['clipseg', ['CLIPSegForImageSegmentation', CLIPSegForImageSegmentation]],
6534
6300
  ]);
6535
6301
 
6536
6302
  const MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES = new Map([
6537
6303
  ['segformer', ['SegformerForSemanticSegmentation', SegformerForSemanticSegmentation]],
6304
+ ['sapiens', ['SapiensForSemanticSegmentation', SapiensForSemanticSegmentation]],
6305
+ ]);
6306
+
6307
+ const MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES = new Map([
6308
+ ['detr', ['DetrForSegmentation', DetrForSegmentation]],
6309
+ ['maskformer', ['MaskFormerForInstanceSegmentation', MaskFormerForInstanceSegmentation]],
6538
6310
  ]);
6539
6311
 
6540
6312
  const MODEL_FOR_MASK_GENERATION_MAPPING_NAMES = new Map([
@@ -6583,6 +6355,12 @@ const MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES = new Map([
6583
6355
  ['dpt', ['DPTForDepthEstimation', DPTForDepthEstimation]],
6584
6356
  ['depth_anything', ['DepthAnythingForDepthEstimation', DepthAnythingForDepthEstimation]],
6585
6357
  ['glpn', ['GLPNForDepthEstimation', GLPNForDepthEstimation]],
6358
+ ['sapiens', ['SapiensForDepthEstimation', SapiensForDepthEstimation]],
6359
+ ['depth_pro', ['DepthProForDepthEstimation', DepthProForDepthEstimation]],
6360
+ ])
6361
+
6362
+ const MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES = new Map([
6363
+ ['sapiens', ['SapiensForNormalEstimation', SapiensForNormalEstimation]],
6586
6364
  ])
6587
6365
 
6588
6366
  // NOTE: This is custom to Transformers.js, and is necessary because certain models
@@ -6607,10 +6385,12 @@ const MODEL_CLASS_TYPE_MAPPING = [
6607
6385
  [MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES, MODEL_TYPES.ImageTextToText],
6608
6386
  [MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES, MODEL_TYPES.EncoderOnly],
6609
6387
  [MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES, MODEL_TYPES.EncoderOnly],
6388
+ [MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES, MODEL_TYPES.EncoderOnly],
6610
6389
  [MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES, MODEL_TYPES.EncoderOnly],
6611
6390
  [MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES, MODEL_TYPES.EncoderOnly],
6612
6391
  [MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES, MODEL_TYPES.EncoderOnly],
6613
6392
  [MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES, MODEL_TYPES.EncoderOnly],
6393
+ [MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES, MODEL_TYPES.EncoderOnly],
6614
6394
  [MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES, MODEL_TYPES.EncoderOnly],
6615
6395
  [MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES, MODEL_TYPES.EncoderOnly],
6616
6396
  [MODEL_FOR_MASK_GENERATION_MAPPING_NAMES, MODEL_TYPES.MaskGeneration],
@@ -6808,6 +6588,17 @@ export class AutoModelForSemanticSegmentation extends PretrainedMixin {
6808
6588
  static MODEL_CLASS_MAPPINGS = [MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES];
6809
6589
  }
6810
6590
 
6591
+ /**
6592
+ * Helper class which is used to instantiate pretrained universal image segmentation models with the `from_pretrained` function.
6593
+ * The chosen model class is determined by the type specified in the model config.
6594
+ *
6595
+ * @example
6596
+ * let model = await AutoModelForUniversalSegmentation.from_pretrained('hf-internal-testing/tiny-random-MaskFormerForInstanceSegmentation');
6597
+ */
6598
+ export class AutoModelForUniversalSegmentation extends PretrainedMixin {
6599
+ static MODEL_CLASS_MAPPINGS = [MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES];
6600
+ }
6601
+
6811
6602
  /**
6812
6603
  * Helper class which is used to instantiate pretrained object detection models with the `from_pretrained` function.
6813
6604
  * The chosen model class is determined by the type specified in the model config.
@@ -6867,6 +6658,10 @@ export class AutoModelForDepthEstimation extends PretrainedMixin {
6867
6658
  static MODEL_CLASS_MAPPINGS = [MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES];
6868
6659
  }
6869
6660
 
6661
+ export class AutoModelForNormalEstimation extends PretrainedMixin {
6662
+ static MODEL_CLASS_MAPPINGS = [MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES];
6663
+ }
6664
+
6870
6665
  export class AutoModelForImageFeatureExtraction extends PretrainedMixin {
6871
6666
  static MODEL_CLASS_MAPPINGS = [MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES];
6872
6667
  }