@huggingface/transformers 3.1.0 → 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.
- package/README.md +7 -3
- package/dist/ort-wasm-simd-threaded.jsep.wasm +0 -0
- package/dist/transformers.cjs +965 -195
- package/dist/transformers.cjs.map +1 -1
- package/dist/transformers.js +2251 -1360
- package/dist/transformers.js.map +1 -1
- package/dist/transformers.min.cjs +1 -352
- package/dist/transformers.min.cjs.map +1 -1
- package/dist/transformers.min.js +1 -415
- package/dist/transformers.min.js.map +1 -1
- package/dist/transformers.min.mjs +1 -352
- package/dist/transformers.min.mjs.map +1 -1
- package/dist/transformers.mjs +979 -194
- package/dist/transformers.mjs.map +1 -1
- package/package.json +11 -16
- package/src/backends/onnx.js +2 -7
- package/src/configs.js +3 -1
- package/src/env.js +6 -6
- package/src/generation/configuration_utils.js +7 -0
- package/src/generation/logits_process.js +22 -16
- package/src/generation/streamers.js +7 -2
- package/src/models/idefics3/image_processing_idefics3.js +219 -0
- package/src/models/idefics3/processing_idefics3.js +136 -0
- package/src/models/image_processors.js +1 -0
- package/src/models/paligemma/processing_paligemma.js +82 -0
- package/src/models/processors.js +2 -0
- package/src/models.js +169 -39
- package/src/tokenizers.js +12 -1
- package/src/utils/core.js +53 -9
- package/src/utils/dtypes.js +2 -1
- package/src/utils/hub.js +8 -12
- package/src/utils/image.js +59 -16
- package/src/utils/tensor.js +6 -1
- package/types/backends/onnx.d.ts +2 -2
- package/types/backends/onnx.d.ts.map +1 -1
- package/types/base/feature_extraction_utils.d.ts +1 -1
- package/types/base/feature_extraction_utils.d.ts.map +1 -1
- package/types/base/image_processors_utils.d.ts +2 -2
- package/types/base/image_processors_utils.d.ts.map +1 -1
- package/types/base/processing_utils.d.ts +4 -4
- package/types/base/processing_utils.d.ts.map +1 -1
- package/types/configs.d.ts +7 -7
- package/types/configs.d.ts.map +1 -1
- package/types/env.d.ts +2 -2
- package/types/env.d.ts.map +1 -1
- package/types/generation/configuration_utils.d.ts +7 -1
- package/types/generation/configuration_utils.d.ts.map +1 -1
- package/types/generation/logits_process.d.ts +32 -22
- package/types/generation/logits_process.d.ts.map +1 -1
- package/types/generation/logits_sampler.d.ts.map +1 -1
- package/types/generation/parameters.d.ts +5 -5
- package/types/generation/stopping_criteria.d.ts +1 -1
- package/types/generation/stopping_criteria.d.ts.map +1 -1
- package/types/generation/streamers.d.ts +15 -10
- package/types/generation/streamers.d.ts.map +1 -1
- package/types/models/audio_spectrogram_transformer/feature_extraction_audio_spectrogram_transformer.d.ts +1 -1
- package/types/models/audio_spectrogram_transformer/feature_extraction_audio_spectrogram_transformer.d.ts.map +1 -1
- package/types/models/auto/feature_extraction_auto.d.ts.map +1 -1
- package/types/models/auto/image_processing_auto.d.ts.map +1 -1
- package/types/models/auto/processing_auto.d.ts +1 -1
- package/types/models/auto/processing_auto.d.ts.map +1 -1
- package/types/models/clap/feature_extraction_clap.d.ts +1 -1
- package/types/models/clap/feature_extraction_clap.d.ts.map +1 -1
- package/types/models/detr/image_processing_detr.d.ts +11 -11
- package/types/models/detr/image_processing_detr.d.ts.map +1 -1
- package/types/models/donut/image_processing_donut.d.ts +1 -1
- package/types/models/donut/image_processing_donut.d.ts.map +1 -1
- package/types/models/florence2/processing_florence2.d.ts.map +1 -1
- package/types/models/idefics3/image_processing_idefics3.d.ts +40 -0
- package/types/models/idefics3/image_processing_idefics3.d.ts.map +1 -0
- package/types/models/idefics3/processing_idefics3.d.ts +19 -0
- package/types/models/idefics3/processing_idefics3.d.ts.map +1 -0
- package/types/models/image_processors.d.ts +1 -0
- package/types/models/janus/image_processing_janus.d.ts +1 -1
- package/types/models/janus/image_processing_janus.d.ts.map +1 -1
- package/types/models/janus/processing_janus.d.ts.map +1 -1
- package/types/models/maskformer/image_processing_maskformer.d.ts +8 -8
- package/types/models/maskformer/image_processing_maskformer.d.ts.map +1 -1
- package/types/models/mgp_str/processing_mgp_str.d.ts +2 -2
- package/types/models/mgp_str/processing_mgp_str.d.ts.map +1 -1
- package/types/models/owlvit/image_processing_owlvit.d.ts.map +1 -1
- package/types/models/paligemma/processing_paligemma.d.ts +12 -0
- package/types/models/paligemma/processing_paligemma.d.ts.map +1 -0
- package/types/models/processors.d.ts +2 -0
- package/types/models/pyannote/feature_extraction_pyannote.d.ts.map +1 -1
- package/types/models/pyannote/processing_pyannote.d.ts +1 -1
- package/types/models/pyannote/processing_pyannote.d.ts.map +1 -1
- package/types/models/qwen2_vl/processing_qwen2_vl.d.ts.map +1 -1
- package/types/models/rt_detr/image_processing_rt_detr.d.ts.map +1 -1
- package/types/models/sam/image_processing_sam.d.ts.map +1 -1
- package/types/models/seamless_m4t/feature_extraction_seamless_m4t.d.ts +1 -1
- package/types/models/seamless_m4t/feature_extraction_seamless_m4t.d.ts.map +1 -1
- package/types/models/segformer/image_processing_segformer.d.ts.map +1 -1
- package/types/models/speecht5/processing_speecht5.d.ts.map +1 -1
- package/types/models/swin2sr/image_processing_swin2sr.d.ts +1 -1
- package/types/models/swin2sr/image_processing_swin2sr.d.ts.map +1 -1
- package/types/models/vitmatte/image_processing_vitmatte.d.ts.map +1 -1
- package/types/models/vitpose/image_processing_vitpose.d.ts +1 -1
- package/types/models/vitpose/image_processing_vitpose.d.ts.map +1 -1
- package/types/models/wav2vec2/feature_extraction_wav2vec2.d.ts.map +1 -1
- package/types/models/wav2vec2/processing_wav2vec2.d.ts.map +1 -1
- package/types/models/wespeaker/feature_extraction_wespeaker.d.ts +1 -1
- package/types/models/wespeaker/feature_extraction_wespeaker.d.ts.map +1 -1
- package/types/models/whisper/feature_extraction_whisper.d.ts +1 -1
- package/types/models/whisper/feature_extraction_whisper.d.ts.map +1 -1
- package/types/models/whisper/generation_whisper.d.ts.map +1 -1
- package/types/models/whisper/processing_whisper.d.ts.map +1 -1
- package/types/models/yolos/image_processing_yolos.d.ts.map +1 -1
- package/types/models.d.ts +44 -10
- package/types/models.d.ts.map +1 -1
- package/types/ops/registry.d.ts.map +1 -1
- package/types/pipelines.d.ts +26 -51
- package/types/pipelines.d.ts.map +1 -1
- package/types/tokenizers.d.ts +10 -6
- package/types/tokenizers.d.ts.map +1 -1
- package/types/utils/audio.d.ts.map +1 -1
- package/types/utils/constants.d.ts.map +1 -1
- package/types/utils/core.d.ts +94 -22
- package/types/utils/core.d.ts.map +1 -1
- package/types/utils/data-structures.d.ts.map +1 -1
- package/types/utils/devices.d.ts.map +1 -1
- package/types/utils/dtypes.d.ts +3 -2
- package/types/utils/dtypes.d.ts.map +1 -1
- package/types/utils/generic.d.ts.map +1 -1
- package/types/utils/hub.d.ts +3 -3
- package/types/utils/hub.d.ts.map +1 -1
- package/types/utils/image.d.ts +14 -1
- package/types/utils/image.d.ts.map +1 -1
- package/types/utils/maths.d.ts +10 -10
- package/types/utils/maths.d.ts.map +1 -1
- package/types/utils/tensor.d.ts +10 -8
- package/types/utils/tensor.d.ts.map +1 -1
package/src/utils/image.js
CHANGED
|
@@ -10,19 +10,17 @@
|
|
|
10
10
|
|
|
11
11
|
import { isNullishDimension } from './core.js';
|
|
12
12
|
import { getFile } from './hub.js';
|
|
13
|
-
import { env } from '../env.js';
|
|
13
|
+
import { env, apis } from '../env.js';
|
|
14
14
|
import { Tensor } from './tensor.js';
|
|
15
15
|
|
|
16
16
|
// Will be empty (or not used) if running in browser or web-worker
|
|
17
17
|
import sharp from 'sharp';
|
|
18
18
|
|
|
19
|
-
const BROWSER_ENV = typeof self !== 'undefined';
|
|
20
|
-
const WEBWORKER_ENV = BROWSER_ENV && self.constructor.name === 'DedicatedWorkerGlobalScope';
|
|
21
|
-
|
|
22
19
|
let createCanvasFunction;
|
|
23
20
|
let ImageDataClass;
|
|
24
21
|
let loadImageFunction;
|
|
25
|
-
|
|
22
|
+
const IS_BROWSER_OR_WEBWORKER = apis.IS_BROWSER_ENV || apis.IS_WEBWORKER_ENV;
|
|
23
|
+
if (IS_BROWSER_OR_WEBWORKER) {
|
|
26
24
|
// Running in browser or web-worker
|
|
27
25
|
createCanvasFunction = (/** @type {number} */ width, /** @type {number} */ height) => {
|
|
28
26
|
if (!self.OffscreenCanvas) {
|
|
@@ -132,7 +130,7 @@ export class RawImage {
|
|
|
132
130
|
* @returns {RawImage} The image object.
|
|
133
131
|
*/
|
|
134
132
|
static fromCanvas(canvas) {
|
|
135
|
-
if (!
|
|
133
|
+
if (!IS_BROWSER_OR_WEBWORKER) {
|
|
136
134
|
throw new Error('fromCanvas() is only supported in browser environments.')
|
|
137
135
|
}
|
|
138
136
|
|
|
@@ -161,7 +159,7 @@ export class RawImage {
|
|
|
161
159
|
* @returns {Promise<RawImage>} The image object.
|
|
162
160
|
*/
|
|
163
161
|
static async fromBlob(blob) {
|
|
164
|
-
if (
|
|
162
|
+
if (IS_BROWSER_OR_WEBWORKER) {
|
|
165
163
|
// Running in environment with canvas
|
|
166
164
|
const img = await loadImageFunction(blob);
|
|
167
165
|
|
|
@@ -305,6 +303,46 @@ export class RawImage {
|
|
|
305
303
|
return this._update(newData, this.width, this.height, 4);
|
|
306
304
|
}
|
|
307
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
|
+
|
|
308
346
|
/**
|
|
309
347
|
* Resize the image to the given dimensions. This method uses the canvas API to perform the resizing.
|
|
310
348
|
* @param {number} width The width of the new image. `null` or `-1` will preserve the aspect ratio.
|
|
@@ -339,7 +377,7 @@ export class RawImage {
|
|
|
339
377
|
height = (width / this.width) * this.height;
|
|
340
378
|
}
|
|
341
379
|
|
|
342
|
-
if (
|
|
380
|
+
if (IS_BROWSER_OR_WEBWORKER) {
|
|
343
381
|
// TODO use `resample` in browser environment
|
|
344
382
|
|
|
345
383
|
// Store number of channels before resizing
|
|
@@ -412,7 +450,7 @@ export class RawImage {
|
|
|
412
450
|
return this;
|
|
413
451
|
}
|
|
414
452
|
|
|
415
|
-
if (
|
|
453
|
+
if (IS_BROWSER_OR_WEBWORKER) {
|
|
416
454
|
// Store number of channels before padding
|
|
417
455
|
const numChannels = this.channels;
|
|
418
456
|
|
|
@@ -461,7 +499,7 @@ export class RawImage {
|
|
|
461
499
|
const crop_width = x_max - x_min + 1;
|
|
462
500
|
const crop_height = y_max - y_min + 1;
|
|
463
501
|
|
|
464
|
-
if (
|
|
502
|
+
if (IS_BROWSER_OR_WEBWORKER) {
|
|
465
503
|
// Store number of channels before resizing
|
|
466
504
|
const numChannels = this.channels;
|
|
467
505
|
|
|
@@ -509,7 +547,7 @@ export class RawImage {
|
|
|
509
547
|
const height_offset = (this.height - crop_height) / 2;
|
|
510
548
|
|
|
511
549
|
|
|
512
|
-
if (
|
|
550
|
+
if (IS_BROWSER_OR_WEBWORKER) {
|
|
513
551
|
// Store number of channels before resizing
|
|
514
552
|
const numChannels = this.channels;
|
|
515
553
|
|
|
@@ -614,7 +652,7 @@ export class RawImage {
|
|
|
614
652
|
}
|
|
615
653
|
|
|
616
654
|
async toBlob(type = 'image/png', quality = 1) {
|
|
617
|
-
if (!
|
|
655
|
+
if (!IS_BROWSER_OR_WEBWORKER) {
|
|
618
656
|
throw new Error('toBlob() is only supported in browser environments.')
|
|
619
657
|
}
|
|
620
658
|
|
|
@@ -640,7 +678,7 @@ export class RawImage {
|
|
|
640
678
|
}
|
|
641
679
|
|
|
642
680
|
toCanvas() {
|
|
643
|
-
if (!
|
|
681
|
+
if (!IS_BROWSER_OR_WEBWORKER) {
|
|
644
682
|
throw new Error('toCanvas() is only supported in browser environments.')
|
|
645
683
|
}
|
|
646
684
|
|
|
@@ -744,8 +782,8 @@ export class RawImage {
|
|
|
744
782
|
*/
|
|
745
783
|
async save(path) {
|
|
746
784
|
|
|
747
|
-
if (
|
|
748
|
-
if (
|
|
785
|
+
if (IS_BROWSER_OR_WEBWORKER) {
|
|
786
|
+
if (apis.IS_WEBWORKER_ENV) {
|
|
749
787
|
throw new Error('Unable to save an image from a Web Worker.')
|
|
750
788
|
}
|
|
751
789
|
|
|
@@ -781,7 +819,7 @@ export class RawImage {
|
|
|
781
819
|
}
|
|
782
820
|
|
|
783
821
|
toSharp() {
|
|
784
|
-
if (
|
|
822
|
+
if (IS_BROWSER_OR_WEBWORKER) {
|
|
785
823
|
throw new Error('toSharp() is only supported in server-side environments.')
|
|
786
824
|
}
|
|
787
825
|
|
|
@@ -794,3 +832,8 @@ export class RawImage {
|
|
|
794
832
|
});
|
|
795
833
|
}
|
|
796
834
|
}
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Helper function to load an image from a URL, path, etc.
|
|
838
|
+
*/
|
|
839
|
+
export const load_image = RawImage.read.bind(RawImage);
|
package/src/utils/tensor.js
CHANGED
|
@@ -32,6 +32,8 @@ const DataTypeMap = Object.freeze({
|
|
|
32
32
|
int64: BigInt64Array,
|
|
33
33
|
uint64: BigUint64Array,
|
|
34
34
|
bool: Uint8Array,
|
|
35
|
+
uint4: Uint8Array,
|
|
36
|
+
int4: Int8Array,
|
|
35
37
|
});
|
|
36
38
|
|
|
37
39
|
/**
|
|
@@ -1353,7 +1355,7 @@ function fullHelper(size, fill_value, dtype, cls) {
|
|
|
1353
1355
|
/**
|
|
1354
1356
|
* Creates a tensor of size size filled with fill_value. The tensor's dtype is inferred from fill_value.
|
|
1355
1357
|
* @param {number[]} size A sequence of integers defining the shape of the output tensor.
|
|
1356
|
-
* @param {number|bigint} fill_value The value to fill the output tensor with.
|
|
1358
|
+
* @param {number|bigint|boolean} fill_value The value to fill the output tensor with.
|
|
1357
1359
|
* @returns {Tensor} The filled tensor.
|
|
1358
1360
|
*/
|
|
1359
1361
|
export function full(size, fill_value) {
|
|
@@ -1365,6 +1367,9 @@ export function full(size, fill_value) {
|
|
|
1365
1367
|
} else if (typeof fill_value === 'bigint') {
|
|
1366
1368
|
dtype = 'int64';
|
|
1367
1369
|
typedArrayCls = BigInt64Array;
|
|
1370
|
+
} else if (typeof fill_value === 'boolean') {
|
|
1371
|
+
dtype = 'bool';
|
|
1372
|
+
typedArrayCls = Uint8Array;
|
|
1368
1373
|
} else {
|
|
1369
1374
|
// TODO: support other dtypes
|
|
1370
1375
|
throw new Error(`Unsupported data type: ${typeof fill_value}`);
|
package/types/backends/onnx.d.ts
CHANGED
|
@@ -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(
|
|
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(
|
|
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":"
|
|
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(
|
|
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
|
|
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(
|
|
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?:
|
|
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;
|
|
1
|
+
{"version":3,"file":"image_processors_utils.d.ts","sourceRoot":"","sources":["../../src/base/image_processors_utils.js"],"names":[],"mappings":"AA+EA;;;;;;;;;GASG;AACH,uDAPG;IAAwB,MAAM,EAAtB,MAAM;IACU,UAAU,EAA1B,MAAM;CACd,cAAQ,MAAM,iBACN,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,iBAClB,OAAO,GACN,KAAQ,CAwEnB;AAGD;;;;;;GAMG;AACH,4DALW,GAAC,iBACD,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAEhB;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAC,EAAE,CAwDtD;AAkPD;;;;;;;;;GASG;AACH,4DARW,GAAC,cACD,MAAM,mBACN,MAAM,gCACN,MAAM,sBACN,GAAG,CAAC,MAAM,CAAC,iBACX,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAChB,KAAK,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,KAAK,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;CAAC,CAAC,CAuE/G;AAGD;;;;;;;G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M,CAAA;KAAC,GAAC,MAAM,uCAE5C;QAAyC,IAAI,GAArC,UAAU,GAAC,WAAW;QACJ,MAAM,GAAxB,OAAO;QACmB,eAAe,GAAzC,MAAM,GAAC,MAAM,EAAE;KACvB,GAAU,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CA6EpC;IAED;;;;OAIG;IACH,mBAHW,YAAY,GACV,IAAI,CAMhB;IAED;;;;;;OAMG;IACH,oCAJW,QAAQ,QACR,GAAG,GACD,CAAC,MAAM,EAAE,MAAM,CAAC,CA4F5B;IAED;;;;OAIG;IACH,cAHW,QAAQ,GACN,OAAO,CAAC,QAAQ,CAAC,CAO7B;IAED;;;;;OAKG;IAEH;;;;;;OAMG;IACH,kBAJW,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(
|
|
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":"
|
|
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"}
|
package/types/configs.d.ts
CHANGED
|
@@ -53,11 +53,11 @@ export class AutoConfig {
|
|
|
53
53
|
*
|
|
54
54
|
* @returns {Promise<PretrainedConfig>} A new instance of the `PretrainedConfig` class.
|
|
55
55
|
*/
|
|
56
|
-
static from_pretrained(pretrained_model_name_or_path: string, { progress_callback, config, cache_dir, local_files_only, revision, }?:
|
|
56
|
+
static from_pretrained(pretrained_model_name_or_path: string, { progress_callback, config, cache_dir, local_files_only, revision, }?: PretrainedOptions): Promise<PretrainedConfig>;
|
|
57
57
|
}
|
|
58
|
-
export type PretrainedOptions = import(
|
|
59
|
-
export type ProgressCallback = import(
|
|
60
|
-
export type ProgressInfo = import(
|
|
58
|
+
export type PretrainedOptions = import("./utils/hub.js").PretrainedOptions;
|
|
59
|
+
export type ProgressCallback = import("./utils/core.js").ProgressCallback;
|
|
60
|
+
export type ProgressInfo = import("./utils/core.js").ProgressInfo;
|
|
61
61
|
/**
|
|
62
62
|
* Transformers.js-specific configuration, possibly present in config.json under the key `transformers.js_config`.
|
|
63
63
|
*/
|
|
@@ -65,7 +65,7 @@ export type TransformersJSConfig = {
|
|
|
65
65
|
/**
|
|
66
66
|
* The data type of the key-value cache.
|
|
67
67
|
*/
|
|
68
|
-
kv_cache_dtype?: import(
|
|
68
|
+
kv_cache_dtype?: import("./utils/tensor.js").DataType | Record<import("./utils/dtypes.js").DataType, import("./utils/tensor.js").DataType>;
|
|
69
69
|
/**
|
|
70
70
|
* Override the free dimensions of the model.
|
|
71
71
|
* See https://onnxruntime.ai/docs/tutorials/web/env-flags-and-session-options.html#freedimensionoverrides
|
|
@@ -75,11 +75,11 @@ export type TransformersJSConfig = {
|
|
|
75
75
|
/**
|
|
76
76
|
* The default device to use for the model.
|
|
77
77
|
*/
|
|
78
|
-
device?: import(
|
|
78
|
+
device?: import("./utils/devices.js").DeviceType;
|
|
79
79
|
/**
|
|
80
80
|
* The default data type to use for the model.
|
|
81
81
|
*/
|
|
82
|
-
dtype?: import(
|
|
82
|
+
dtype?: import("./utils/dtypes.js").DataType | Record<string, import("./utils/dtypes.js").DataType>;
|
|
83
83
|
/**
|
|
84
84
|
* Whether to load the model using the external data format (used for models >= 2GB in size).
|
|
85
85
|
*/
|
package/types/configs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../src/configs.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../src/configs.js"],"names":[],"mappings":"AAmOA;;;;GAIG;AACH,0CAHW,gBAAgB;;;IACd,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CA2EpC;AACD;;;GAGG;AACH;IAwBI;;;;;;;;OAQG;IACH,sDANW,MAAM,0EACN,iBAAiB,GAGf,OAAO,CAAC,gBAAgB,CAAC,CAqBrC;IArCD;;;OAGG;IACH,6BAGC;IAnBD,0BAA0B;IAC1B,YADW,MAAM,GAAC,IAAI,CACJ;IAElB,sBAAsB;IACtB,oBADW,OAAO,CACS;IAE3B,qBAAqB;IACrB,yBADW,MAAM,CACO;IAExB,mCAAmC;IACnC,0BADW,oBAAoB,CACN;IAQrB,uBAAkD;CAgCzD;AAED;;;;;GAKG;AACH;IArCI;;;;;;;;OAQG;IACH,sDANW,MAAM,0EACN,iBAAiB,GAGf,OAAO,CAAC,gBAAgB,CAAC,CAqBrC;CAcJ;gCArVY,OAAO,gBAAgB,EAAE,iBAAiB;+BAI1C,OAAO,iBAAiB,EAAE,gBAAgB;2BAI1C,OAAO,iBAAiB,EAAE,YAAY;;;;;;;;qBAkVrC,OAAO,mBAAmB,EAAE,QAAQ,GAAC,MAAM,CAAC,OAAO,mBAAmB,EAAE,QAAQ,EAAE,OAAO,mBAAmB,EAAE,QAAQ,CAAC;;;;;;+BACvH,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;aAGtB,OAAO,oBAAoB,EAAE,UAAU;;;;YACvC,OAAO,mBAAmB,EAAE,QAAQ,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,mBAAmB,EAAE,QAAQ,CAAC;;;;+BACzF,OAAO,GAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC"}
|
package/types/env.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* A read-only object containing information about the APIs available in the current environment.
|
|
3
3
|
*/
|
|
4
4
|
export const apis: Readonly<{
|
|
5
|
-
/** Whether we are running in a browser environment */
|
|
5
|
+
/** Whether we are running in a browser environment (and not a web worker) */
|
|
6
6
|
IS_BROWSER_ENV: boolean;
|
|
7
7
|
/** Whether we are running in a web worker environment */
|
|
8
8
|
IS_WEBWORKER_ENV: boolean;
|
|
@@ -57,7 +57,7 @@ export type TransformersEnvironment = {
|
|
|
57
57
|
* allowing users to set these variables if they want to.
|
|
58
58
|
*/
|
|
59
59
|
backends: {
|
|
60
|
-
onnx: Partial<import(
|
|
60
|
+
onnx: Partial<import("onnxruntime-common").Env>;
|
|
61
61
|
};
|
|
62
62
|
/**
|
|
63
63
|
* Whether to allow loading of remote files, defaults to `true`.
|
package/types/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.js"],"names":[],"mappings":"AA0CA;;GAEG;AACH;IACI,
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.js"],"names":[],"mappings":"AA0CA;;GAEG;AACH;IACI,6EAA6E;;IAG7E,yDAAyD;;IAGzD,yCAAyC;;IAGzC,0CAA0C;;IAG1C,yCAAyC;;IAGzC,mDAAmD;;IAGnD,sDAAsD;;IAGtD,8CAA8C;;IAG9C,wCAAwC;;GAEzC;AA6BH;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,sCAAsC;AACtC,kBADW,uBAAuB,CA6BjC;;;;;;;;aAhDa,MAAM;;;;;cACN;QAAC,IAAI,EAAE,OAAO,CAAC,OAAO,oBAAoB,EAAE,GAAG,CAAC,CAAA;KAAC;;;;;uBAEjD,OAAO;;;;gBAEP,MAAM;;;;wBACN,MAAM;;;;;sBACN,OAAO;;;;oBAEP,MAAM;;;;WACN,OAAO;;;;qBACP,OAAO;;;;gBACP,OAAO;;;;cACP,MAAM;;;;oBACN,OAAO"}
|
|
@@ -6,7 +6,7 @@ export class GenerationConfig {
|
|
|
6
6
|
*
|
|
7
7
|
* @param {GenerationConfig|import('../configs.js').PretrainedConfig} config
|
|
8
8
|
*/
|
|
9
|
-
constructor(config: GenerationConfig | import(
|
|
9
|
+
constructor(config: GenerationConfig | import("../configs.js").PretrainedConfig);
|
|
10
10
|
/**
|
|
11
11
|
* The maximum length the generated tokens can have.
|
|
12
12
|
* Corresponds to the length of the input prompt + `max_new_tokens`.
|
|
@@ -223,6 +223,12 @@ export class GenerationConfig {
|
|
|
223
223
|
* @default null
|
|
224
224
|
*/
|
|
225
225
|
suppress_tokens: number[];
|
|
226
|
+
/**
|
|
227
|
+
* A streamer that will be used to stream the generation.
|
|
228
|
+
* @type {import('./streamers.js').TextStreamer}
|
|
229
|
+
* @default null
|
|
230
|
+
*/
|
|
231
|
+
streamer: import("./streamers.js").TextStreamer;
|
|
226
232
|
/**
|
|
227
233
|
* A list of tokens that will be suppressed at the beginning of the generation.
|
|
228
234
|
* The `SuppressBeginTokens` logit processor will set their log probs to `-inf` so that they are not sampled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration_utils.d.ts","sourceRoot":"","sources":["../../src/generation/configuration_utils.js"],"names":[],"mappings":"AAOA;;GAEG;AACH;
|
|
1
|
+
{"version":3,"file":"configuration_utils.d.ts","sourceRoot":"","sources":["../../src/generation/configuration_utils.js"],"names":[],"mappings":"AAOA;;GAEG;AACH;IAiXI;;;OAGG;IACH,oBAFW,gBAAgB,GAAC,OAAO,eAAe,EAAE,gBAAgB,EAInE;IArXD;;;;;;OAMG;IACH,YAHU,MAAM,CAGA;IAEhB;;;;OAIG;IACH,gBAHU,MAAM,CAGM;IAEtB;;;;;;OAMG;IACH,YAHU,MAAM,CAGD;IAEf;;;;OAIG;IACH,gBAHU,MAAM,CAGM;IAEtB;;;;;;;OAOG;IACH,gBAHU,OAAO,GAAC,OAAO,CAGF;IAEvB;;;;;OAKG;IACH,UAHU,MAAM,CAGA;IAGhB;;;;OAIG;IACH,WAHU,OAAO,CAGC;IAElB;;;;OAIG;IACH,WAHU,MAAM,CAGF;IAEd;;;;;OAKG;IACH,iBAHU,MAAM,CAGI;IAEpB;;;;OAIG;IACH,eAHU,MAAM,CAGK;IAErB;;;;OAIG;IACH,WAHU,OAAO,CAGA;IAGjB;;;;OAIG;IACH,aAHU,MAAM,CAGE;IAElB;;;;OAIG;IACH,OAHU,MAAM,CAGL;IAEX;;;;OAIG;IACH,OAHU,MAAM,CAGJ;IAEZ;;;;;;OAMG;IACH,WAHU,MAAM,CAGA;IAEhB;;;;;;OAMG;IACH,gBAHU,MAAM,CAGK;IAErB;;;;;;;OAOG;IACH,YAHU,MAAM,CAGC;IAEjB;;;;;OAKG;IACH,mBA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IAGpB;;;;OAIG;IACH,8BAHU,MAAM,CAGiB;IAEjC;;;;OAIG;IACH,wBAHU,MAAM,CAGc;IAG9B;;;;;OAKG;IACH,uBAAuB;CAS1B"}
|
|
@@ -64,7 +64,7 @@ export class LogitsProcessorList extends LogitsProcessorList_base {
|
|
|
64
64
|
* @param {Tensor} logits
|
|
65
65
|
*/
|
|
66
66
|
_call(input_ids: bigint[][], logits: Tensor): Tensor;
|
|
67
|
-
[Symbol.iterator]():
|
|
67
|
+
[Symbol.iterator](): ArrayIterator<any>;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* A LogitsProcessor that forces a BOS token at the beginning of the generated sequence.
|
|
@@ -80,9 +80,9 @@ export class ForcedBOSTokenLogitsProcessor extends LogitsProcessor {
|
|
|
80
80
|
* Apply the BOS token forcing to the logits.
|
|
81
81
|
* @param {bigint[][]} input_ids The input IDs.
|
|
82
82
|
* @param {Tensor} logits The logits.
|
|
83
|
-
* @returns {
|
|
83
|
+
* @returns {Tensor} The logits with BOS token forcing.
|
|
84
84
|
*/
|
|
85
|
-
_call(input_ids: bigint[][], logits: Tensor):
|
|
85
|
+
_call(input_ids: bigint[][], logits: Tensor): Tensor;
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* A logits processor that enforces the specified token as the last generated token when `max_length` is reached.
|
|
@@ -122,9 +122,9 @@ export class SuppressTokensAtBeginLogitsProcessor extends LogitsProcessor {
|
|
|
122
122
|
* Apply the BOS token forcing to the logits.
|
|
123
123
|
* @param {bigint[][]} input_ids The input IDs.
|
|
124
124
|
* @param {Tensor} logits The logits.
|
|
125
|
-
* @returns {
|
|
125
|
+
* @returns {Tensor} The logits with BOS token forcing.
|
|
126
126
|
*/
|
|
127
|
-
_call(input_ids: bigint[][], logits: Tensor):
|
|
127
|
+
_call(input_ids: bigint[][], logits: Tensor): Tensor;
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
* A LogitsProcessor that handles adding timestamps to generated text.
|
|
@@ -135,7 +135,7 @@ export class WhisperTimeStampLogitsProcessor extends LogitsProcessor {
|
|
|
135
135
|
* @param {import('../models/whisper/generation_whisper.js').WhisperGenerationConfig} generate_config The config object passed to the `generate()` method of a transformer model.
|
|
136
136
|
* @param {number[]} init_tokens The initial tokens of the input sequence.
|
|
137
137
|
*/
|
|
138
|
-
constructor(generate_config: import(
|
|
138
|
+
constructor(generate_config: import("../models/whisper/generation_whisper.js").WhisperGenerationConfig, init_tokens: number[]);
|
|
139
139
|
eos_token_id: number;
|
|
140
140
|
no_timestamps_token_id: number;
|
|
141
141
|
timestamp_begin: number;
|
|
@@ -182,17 +182,27 @@ export class NoRepeatNGramLogitsProcessor extends LogitsProcessor {
|
|
|
182
182
|
* Apply the no-repeat-ngram processor to the logits.
|
|
183
183
|
* @param {bigint[][]} input_ids The input IDs.
|
|
184
184
|
* @param {Tensor} logits The logits.
|
|
185
|
-
* @returns {
|
|
185
|
+
* @returns {Tensor} The logits with no-repeat-ngram processing.
|
|
186
186
|
*/
|
|
187
|
-
_call(input_ids: bigint[][], logits: Tensor):
|
|
187
|
+
_call(input_ids: bigint[][], logits: Tensor): Tensor;
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
|
-
* A logits processor that
|
|
190
|
+
* A logits processor that prevents the repetition of previous tokens through a penalty.
|
|
191
|
+
* This penalty is applied at most once per token. Note that, for decoder-only models like most LLMs,
|
|
192
|
+
* the considered tokens include the prompt.
|
|
193
|
+
*
|
|
194
|
+
* In the original [paper](https://arxiv.org/pdf/1909.05858.pdf), the authors suggest the use of a
|
|
195
|
+
* penalty of around 1.2 to achieve a good balance between truthful generation and lack of repetition.
|
|
196
|
+
* To penalize and reduce repetition, use `penalty` values above 1.0, where a higher value penalizes
|
|
197
|
+
* more strongly. To reward and encourage repetition, use `penalty` values between 0.0 and 1.0, where
|
|
198
|
+
* a lower value rewards more strongly.
|
|
191
199
|
*/
|
|
192
200
|
export class RepetitionPenaltyLogitsProcessor extends LogitsProcessor {
|
|
193
201
|
/**
|
|
194
202
|
* Create a RepetitionPenaltyLogitsProcessor.
|
|
195
|
-
* @param {number} penalty The
|
|
203
|
+
* @param {number} penalty The parameter for repetition penalty.
|
|
204
|
+
* - 1.0 means no penalty. Above 1.0 penalizes previously generated tokens.
|
|
205
|
+
* - Between 0.0 and 1.0 rewards previously generated tokens.
|
|
196
206
|
*/
|
|
197
207
|
constructor(penalty: number);
|
|
198
208
|
penalty: number;
|
|
@@ -200,9 +210,9 @@ export class RepetitionPenaltyLogitsProcessor extends LogitsProcessor {
|
|
|
200
210
|
* Apply the repetition penalty to the logits.
|
|
201
211
|
* @param {bigint[][]} input_ids The input IDs.
|
|
202
212
|
* @param {Tensor} logits The logits.
|
|
203
|
-
* @returns {
|
|
213
|
+
* @returns {Tensor} The logits with repetition penalty processing.
|
|
204
214
|
*/
|
|
205
|
-
_call(input_ids: bigint[][], logits: Tensor):
|
|
215
|
+
_call(input_ids: bigint[][], logits: Tensor): Tensor;
|
|
206
216
|
}
|
|
207
217
|
/**
|
|
208
218
|
* A logits processor that enforces a minimum number of tokens.
|
|
@@ -220,9 +230,9 @@ export class MinLengthLogitsProcessor extends LogitsProcessor {
|
|
|
220
230
|
* Apply logit processor.
|
|
221
231
|
* @param {bigint[][]} input_ids The input IDs.
|
|
222
232
|
* @param {Tensor} logits The logits.
|
|
223
|
-
* @returns {
|
|
233
|
+
* @returns {Tensor} The processed logits.
|
|
224
234
|
*/
|
|
225
|
-
_call(input_ids: bigint[][], logits: Tensor):
|
|
235
|
+
_call(input_ids: bigint[][], logits: Tensor): Tensor;
|
|
226
236
|
}
|
|
227
237
|
/**
|
|
228
238
|
* A logits processor that enforces a minimum number of new tokens.
|
|
@@ -242,9 +252,9 @@ export class MinNewTokensLengthLogitsProcessor extends LogitsProcessor {
|
|
|
242
252
|
* Apply logit processor.
|
|
243
253
|
* @param {bigint[][]} input_ids The input IDs.
|
|
244
254
|
* @param {Tensor} logits The logits.
|
|
245
|
-
* @returns {
|
|
255
|
+
* @returns {Tensor} The processed logits.
|
|
246
256
|
*/
|
|
247
|
-
_call(input_ids: bigint[][], logits: Tensor):
|
|
257
|
+
_call(input_ids: bigint[][], logits: Tensor): Tensor;
|
|
248
258
|
}
|
|
249
259
|
export class NoBadWordsLogitsProcessor extends LogitsProcessor {
|
|
250
260
|
/**
|
|
@@ -259,9 +269,9 @@ export class NoBadWordsLogitsProcessor extends LogitsProcessor {
|
|
|
259
269
|
* Apply logit processor.
|
|
260
270
|
* @param {bigint[][]} input_ids The input IDs.
|
|
261
271
|
* @param {Tensor} logits The logits.
|
|
262
|
-
* @returns {
|
|
272
|
+
* @returns {Tensor} The processed logits.
|
|
263
273
|
*/
|
|
264
|
-
_call(input_ids: bigint[][], logits: Tensor):
|
|
274
|
+
_call(input_ids: bigint[][], logits: Tensor): Tensor;
|
|
265
275
|
}
|
|
266
276
|
/**
|
|
267
277
|
* [`LogitsProcessor`] for classifier free guidance (CFG). The scores are split over the batch dimension,
|
|
@@ -284,9 +294,9 @@ export class ClassifierFreeGuidanceLogitsProcessor extends LogitsProcessor {
|
|
|
284
294
|
* Apply logit processor.
|
|
285
295
|
* @param {bigint[][]} input_ids The input IDs.
|
|
286
296
|
* @param {Tensor} logits The logits.
|
|
287
|
-
* @returns {
|
|
297
|
+
* @returns {Tensor} The processed logits.
|
|
288
298
|
*/
|
|
289
|
-
_call(input_ids: bigint[][], logits: Tensor):
|
|
299
|
+
_call(input_ids: bigint[][], logits: Tensor): Tensor;
|
|
290
300
|
}
|
|
291
301
|
/**
|
|
292
302
|
* [`LogitsWarper`] for temperature (exponential scaling output probability distribution), which effectively means
|
|
@@ -305,9 +315,9 @@ export class TemperatureLogitsWarper extends LogitsWarper {
|
|
|
305
315
|
* Apply logit warper.
|
|
306
316
|
* @param {bigint[][]} input_ids The input IDs.
|
|
307
317
|
* @param {Tensor} logits The logits.
|
|
308
|
-
* @returns {
|
|
318
|
+
* @returns {Tensor} The processed logits.
|
|
309
319
|
*/
|
|
310
|
-
_call(input_ids: bigint[][], logits: Tensor):
|
|
320
|
+
_call(input_ids: bigint[][], logits: Tensor): Tensor;
|
|
311
321
|
}
|
|
312
322
|
/**
|
|
313
323
|
* [`LogitsWarper`] that performs top-p, i.e. restricting to top tokens summing to prob_cut_off <= prob_cut_off.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logits_process.d.ts","sourceRoot":"","sources":["../../src/generation/logits_process.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logits_process.d.ts","sourceRoot":"","sources":["../../src/generation/logits_process.js"],"names":[],"mappings":";KAQW,GAAG;UAAyB,GAAG;;AAE1C;;GAEG;AACH;IACI;;;;;;;OAOG;IACH,iBAJW,MAAM,EAAE,EAAE,UACV,MAAM,QAKhB;CACJ;;KAjBU,GAAG;UAAyB,GAAG;;AAoB1C;;GAEG;AACH;IACI;;;;;;;OAOG;IACH,iBAJW,MAAM,EAAE,EAAE,UACV,MAAM,QAKhB;CACJ;;KAnCU,GAAG;UAAyB,GAAG;;AAsC1C;;;;GAIG;AACH;IAMQ,kBAAoB;IAGxB;;;;OAIG;IACH,WAFW,eAAe,QAIzB;IAED;;;;OAIG;IACH,cAFW,eAAe,EAAE,QAI3B;IAED;;;;;OAKG;IACH,iBAHW,MAAM,EAAE,EAAE,UACV,MAAM,UAShB;IAED,wCAEC;CACJ;AAwCD;;GAEG;AACH;IACI;;;OAGG;IACH,0BAFW,MAAM,EAKhB;IADG,qBAAgC;IAGpC;;;;;OAKG;IACH,iBAJW,MAAM,EAAE,EAAE,UACV,MAAM,GACJ,MAAM,CAWlB;CACJ;AAED;;GAEG;AACH;IACI;;;;OAIG;IACH,wBAHW,MAAM,gBACN,MAAM,GAAC,MAAM,EAAE,EAMzB;IAFG,mBAA4B;IAC5B,uBAA+E;IAGnF;;;;;OAKG;IACH,iBAHW,MAAM,EAAE,EAAE,UACV,MAAM,UAahB;CACJ;AAED;;;;GAIG;AACH;IACI;;;;OAIG;IACH,mCAHW,MAA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AAM,kBACN,MAAM,gBACN,MAAM,GAAC,MAAM,EAAE,EAOzB;IAHG,8BAAkD;IAClD,uBAAoC;IACpC,uBAA+E;IAGnF;;;;;OAKG;IACH,iBAJW,MAAM,EAAE,EAAE,UACV,MAAM,GACJ,MAAM,CAclB;CACJ;AAED;IACI;;;;OAIG;IACH,2BAHW,MAAM,EAAE,EAAE,gBACV,MAAM,GAAC,MAAM,EAAE,EAMzB;IAFG,0BAAkC;IAClC,uBAA+E;IAGnF;;;;;OAKG;IACH,iBAJW,MAAM,EAAE,EAAE,UACV,MAAM,GACJ,MAAM,CA4BlB;CACJ;AAED;;;;;;;GAOG;AACH;IAEI;;;;;OAKG;IACH,4BAJW,MAAM,EAYhB;IADG,uBAAoC;IAGxC;;;;;OAKG;IACH,iBAJW,MAAM,EAAE,EAAE,UACV,MAAM,GACJ,MAAM,CAsBlB;CACJ;AAED;;;GAGG;AACH;IACI;;;;;OAKG;IACH,yBAJW,MAAM,EAgBhB;IADG,oBAA8B;IAGlC;;;;;OAKG;IACH,iBAJW,MAAM,EAAE,EAAE,UACV,MAAM,GACJ,MAAM,CAQlB;CACJ;AAED;;;GAGG;AACH;IACI;;;;;;;OAOG;IACH,mBANW,MAAM,0CAGd;QAAyB,YAAY,GAA7B,MAAM;QACW,kBAAkB,GAAnC,MAAM;KAChB,EAgBA;IAHG,cAAkB;IAClB,qBAAgC;IAChC,2BAA4C;CAEnD;AAED;;;GAGG;AACH;IACI;;;;;;OAMG;IACH,mBALW,MAAM,0CAEd;QAAyB,YAAY,GAA7B,MAAM;QACW,kBAAkB,GAAnC,MAAM;KAChB,EAYA;IAFG,cAAgD;IAChD,qBAAgC;CAEvC;uBA9sBsB,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logits_sampler.d.ts","sourceRoot":"","sources":["../../src/generation/logits_sampler.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logits_sampler.d.ts","sourceRoot":"","sources":["../../src/generation/logits_sampler.js"],"names":[],"mappings":";KAQK,GAAG;UAGN,GAAG;;AAGL;;GAEG;AACH;IAyEI;;;;OAIG;IACH,qCAHW,gBAAgB,GACd,aAAa,CAwBzB;IAnGD;;;OAGG;IACH,+BAFW,gBAAgB,EAK1B;IADG,oCAA0C;IAG9C;;;;OAIG;IACH,cAHW,MAAM,GACJ,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAMvC;IAED;;;;;OAKG;IACH,eAJW,MAAM,GAEJ,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAIvC;IAED;;;;;OAKG;IACH,kBAJW,MAAM,SACN,MAAM,GACJ,YAAY,CAcxB;IAED;;;;OAIG;IACH,4BAHW,OAAO,oBAAoB,EAAE,SAAS,GACpC,MAAM,CAiBlB;CA8BJ;iCA1GgC,sCAAsC;uBAN1C,oBAAoB"}
|
|
@@ -6,7 +6,7 @@ type GenerationFunctionParameters = {
|
|
|
6
6
|
* should be in the format of `input_ids`. For encoder-decoder models *inputs* can represent any of
|
|
7
7
|
* `input_ids`, `input_values`, `input_features`, or `pixel_values`.
|
|
8
8
|
*/
|
|
9
|
-
inputs?: import(
|
|
9
|
+
inputs?: import("../utils/tensor.js").Tensor;
|
|
10
10
|
/**
|
|
11
11
|
* (`GenerationConfig`, *optional*):
|
|
12
12
|
* The generation configuration to be used as base parametrization for the generation call.
|
|
@@ -17,27 +17,27 @@ type GenerationFunctionParameters = {
|
|
|
17
17
|
* - (2) from the model configuration. Please note that unspecified parameters will inherit [`GenerationConfig`]'s
|
|
18
18
|
* default values, whose documentation should be checked to parameterize generation.
|
|
19
19
|
*/
|
|
20
|
-
generation_config?: import(
|
|
20
|
+
generation_config?: import("./configuration_utils.js").GenerationConfig;
|
|
21
21
|
/**
|
|
22
22
|
* (`LogitsProcessorList`, *optional*):
|
|
23
23
|
* Custom logits processors that complement the default logits processors built from arguments and
|
|
24
24
|
* generation config. If a logit processor is passed that is already created with the arguments or a
|
|
25
25
|
* generation config an error is thrown. This feature is intended for advanced users.
|
|
26
26
|
*/
|
|
27
|
-
logits_processor?: import(
|
|
27
|
+
logits_processor?: import("./logits_process.js").LogitsProcessorList;
|
|
28
28
|
/**
|
|
29
29
|
* (`StoppingCriteriaList`, *optional*):
|
|
30
30
|
* Custom stopping criteria that complements the default stopping criteria built from arguments and a
|
|
31
31
|
* generation config. If a stopping criteria is passed that is already created with the arguments or a
|
|
32
32
|
* generation config an error is thrown. This feature is intended for advanced users.
|
|
33
33
|
*/
|
|
34
|
-
stopping_criteria?: import(
|
|
34
|
+
stopping_criteria?: import("./stopping_criteria.js").StoppingCriteriaList;
|
|
35
35
|
/**
|
|
36
36
|
* (`BaseStreamer`, *optional*):
|
|
37
37
|
* Streamer object that will be used to stream the generated sequences. Generated tokens are passed
|
|
38
38
|
* through `streamer.put(token_ids)` and the streamer is responsible for any further processing.
|
|
39
39
|
*/
|
|
40
|
-
streamer?: import(
|
|
40
|
+
streamer?: import("./streamers.js").BaseStreamer;
|
|
41
41
|
/**
|
|
42
42
|
* (`number[]`, *optional*):
|
|
43
43
|
* If the model is an encoder-decoder model, this argument is used to pass the `decoder_input_ids`.
|
|
@@ -38,7 +38,7 @@ export class StoppingCriteriaList extends StoppingCriteriaList_base {
|
|
|
38
38
|
*/
|
|
39
39
|
extend(items: StoppingCriteria | StoppingCriteriaList | StoppingCriteria[]): void;
|
|
40
40
|
_call(input_ids: any, scores: any): any[];
|
|
41
|
-
[Symbol.iterator]():
|
|
41
|
+
[Symbol.iterator](): ArrayIterator<any>;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* This class can be used to stop generation whenever the full generated number of tokens exceeds `max_length`.
|