@huggingface/transformers 3.0.0-alpha.2 → 3.0.0-alpha.20
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 +19 -9
- package/dist/ort-wasm-simd-threaded.jsep.wasm +0 -0
- package/dist/transformers.cjs +2402 -2039
- package/dist/transformers.cjs.map +1 -1
- package/dist/transformers.js +3423 -2999
- package/dist/transformers.js.map +1 -1
- package/dist/transformers.min.cjs +37 -43
- package/dist/transformers.min.cjs.map +1 -1
- package/dist/transformers.min.js +39 -40
- package/dist/transformers.min.js.map +1 -1
- package/dist/transformers.min.mjs +63 -70
- package/dist/transformers.min.mjs.map +1 -1
- package/dist/transformers.mjs +2452 -2063
- package/dist/transformers.mjs.map +1 -1
- package/package.json +23 -13
- package/src/backends/onnx.js +98 -36
- package/src/configs.js +18 -4
- package/src/env.js +9 -9
- package/src/generation/logits_process.js +40 -37
- package/src/generation/streamers.js +3 -3
- package/src/models.js +238 -74
- package/src/ops/registry.js +14 -3
- package/src/pipelines.js +5 -4
- package/src/processors.js +390 -351
- package/src/tokenizers.js +139 -174
- package/src/utils/core.js +12 -0
- package/src/utils/data-structures.js +13 -11
- package/src/utils/devices.js +15 -4
- package/src/utils/dtypes.js +1 -3
- package/src/utils/hub.js +18 -17
- package/src/utils/maths.js +14 -5
- package/src/utils/tensor.js +23 -0
- package/types/backends/onnx.d.ts +6 -5
- package/types/backends/onnx.d.ts.map +1 -1
- package/types/configs.d.ts +29 -3
- package/types/configs.d.ts.map +1 -1
- package/types/env.d.ts +6 -2
- package/types/env.d.ts.map +1 -1
- package/types/generation/logits_process.d.ts.map +1 -1
- package/types/models.d.ts +108 -2
- package/types/models.d.ts.map +1 -1
- package/types/ops/registry.d.ts +6 -6
- package/types/ops/registry.d.ts.map +1 -1
- package/types/pipelines.d.ts.map +1 -1
- package/types/processors.d.ts +55 -51
- package/types/processors.d.ts.map +1 -1
- package/types/tokenizers.d.ts +23 -32
- package/types/tokenizers.d.ts.map +1 -1
- package/types/utils/core.d.ts +7 -0
- package/types/utils/core.d.ts.map +1 -1
- package/types/utils/data-structures.d.ts +6 -6
- package/types/utils/data-structures.d.ts.map +1 -1
- package/types/utils/devices.d.ts +11 -1
- package/types/utils/devices.d.ts.map +1 -1
- package/types/utils/dtypes.d.ts +0 -3
- package/types/utils/dtypes.d.ts.map +1 -1
- package/types/utils/hub.d.ts +2 -41
- package/types/utils/hub.d.ts.map +1 -1
- package/types/utils/maths.d.ts +2 -2
- package/types/utils/maths.d.ts.map +1 -1
- package/types/utils/tensor.d.ts +13 -1
- package/types/utils/tensor.d.ts.map +1 -1
package/types/processors.d.ts
CHANGED
|
@@ -166,19 +166,34 @@ export class ImageFeatureExtractor extends FeatureExtractor {
|
|
|
166
166
|
*/
|
|
167
167
|
_call(images: RawImage[], ...args: any[]): Promise<ImageFeatureExtractorResult>;
|
|
168
168
|
}
|
|
169
|
+
export class SapiensFeatureExtractor extends ImageFeatureExtractor {
|
|
170
|
+
/**
|
|
171
|
+
* Post-processes the outputs of the model (for semantic segmentation).
|
|
172
|
+
* @param {*} outputs Raw outputs of the model.
|
|
173
|
+
* @param {[number, number][]} [target_sizes=null] List of tuples corresponding to the requested final size
|
|
174
|
+
* (height, width) of each prediction. If unset, predictions will not be resized.
|
|
175
|
+
* @returns {{segmentation: Tensor; labels: number[]}[]} The semantic segmentation maps.
|
|
176
|
+
*/
|
|
177
|
+
post_process_semantic_segmentation(outputs: any, target_sizes?: [number, number][]): {
|
|
178
|
+
segmentation: Tensor;
|
|
179
|
+
labels: number[];
|
|
180
|
+
}[];
|
|
181
|
+
}
|
|
169
182
|
export class SegformerFeatureExtractor extends ImageFeatureExtractor {
|
|
170
183
|
/**
|
|
171
|
-
*
|
|
184
|
+
* Post-processes the outputs of the model (for semantic segmentation).
|
|
172
185
|
* @param {*} outputs Raw outputs of the model.
|
|
173
|
-
* @param {number
|
|
186
|
+
* @param {[number, number][]} [target_sizes=null] List of tuples corresponding to the requested final size
|
|
174
187
|
* (height, width) of each prediction. If unset, predictions will not be resized.
|
|
175
188
|
* @returns {{segmentation: Tensor; labels: number[]}[]} The semantic segmentation maps.
|
|
176
189
|
*/
|
|
177
|
-
post_process_semantic_segmentation(outputs: any, target_sizes?: number
|
|
190
|
+
post_process_semantic_segmentation(outputs: any, target_sizes?: [number, number][]): {
|
|
178
191
|
segmentation: Tensor;
|
|
179
192
|
labels: number[];
|
|
180
193
|
}[];
|
|
181
194
|
}
|
|
195
|
+
export class PvtImageProcessor extends ImageFeatureExtractor {
|
|
196
|
+
}
|
|
182
197
|
export class DPTFeatureExtractor extends ImageFeatureExtractor {
|
|
183
198
|
}
|
|
184
199
|
export class DPTImageProcessor extends DPTFeatureExtractor {
|
|
@@ -232,7 +247,7 @@ export class OwlViTFeatureExtractor extends ImageFeatureExtractor {
|
|
|
232
247
|
* @param {Tensor} outputs.logits The logits
|
|
233
248
|
* @param {Tensor} outputs.pred_boxes The predicted boxes.
|
|
234
249
|
* @param {number} [threshold=0.5] The threshold to use for the scores.
|
|
235
|
-
* @param {number
|
|
250
|
+
* @param {[number, number][]} [target_sizes=null] The sizes of the original images.
|
|
236
251
|
* @param {boolean} [is_zero_shot=false] Whether zero-shot object detection was performed.
|
|
237
252
|
* @return {Object[]} An array of objects containing the post-processed outputs.
|
|
238
253
|
* @private
|
|
@@ -240,7 +255,7 @@ export class OwlViTFeatureExtractor extends ImageFeatureExtractor {
|
|
|
240
255
|
post_process_object_detection(outputs: {
|
|
241
256
|
logits: Tensor;
|
|
242
257
|
pred_boxes: Tensor;
|
|
243
|
-
}, threshold?: number, target_sizes?: number
|
|
258
|
+
}, threshold?: number, target_sizes?: [number, number][], is_zero_shot?: boolean): any[];
|
|
244
259
|
}
|
|
245
260
|
export class Owlv2ImageProcessor extends OwlViTFeatureExtractor {
|
|
246
261
|
}
|
|
@@ -251,7 +266,7 @@ export class RTDetrImageProcessor extends ImageFeatureExtractor {
|
|
|
251
266
|
* @param {Tensor} outputs.logits The logits
|
|
252
267
|
* @param {Tensor} outputs.pred_boxes The predicted boxes.
|
|
253
268
|
* @param {number} [threshold=0.5] The threshold to use for the scores.
|
|
254
|
-
* @param {number
|
|
269
|
+
* @param {[number, number][]} [target_sizes=null] The sizes of the original images.
|
|
255
270
|
* @param {boolean} [is_zero_shot=false] Whether zero-shot object detection was performed.
|
|
256
271
|
* @return {Object[]} An array of objects containing the post-processed outputs.
|
|
257
272
|
* @private
|
|
@@ -259,7 +274,7 @@ export class RTDetrImageProcessor extends ImageFeatureExtractor {
|
|
|
259
274
|
post_process_object_detection(outputs: {
|
|
260
275
|
logits: Tensor;
|
|
261
276
|
pred_boxes: Tensor;
|
|
262
|
-
}, threshold?: number, target_sizes?: number
|
|
277
|
+
}, threshold?: number, target_sizes?: [number, number][], is_zero_shot?: boolean): any[];
|
|
263
278
|
}
|
|
264
279
|
export class DeiTFeatureExtractor extends ImageFeatureExtractor {
|
|
265
280
|
}
|
|
@@ -294,7 +309,7 @@ export class DetrFeatureExtractor extends ImageFeatureExtractor {
|
|
|
294
309
|
* @param {Tensor} outputs.logits The logits
|
|
295
310
|
* @param {Tensor} outputs.pred_boxes The predicted boxes.
|
|
296
311
|
* @param {number} [threshold=0.5] The threshold to use for the scores.
|
|
297
|
-
* @param {number
|
|
312
|
+
* @param {[number, number][]} [target_sizes=null] The sizes of the original images.
|
|
298
313
|
* @param {boolean} [is_zero_shot=false] Whether zero-shot object detection was performed.
|
|
299
314
|
* @return {Object[]} An array of objects containing the post-processed outputs.
|
|
300
315
|
* @private
|
|
@@ -302,42 +317,7 @@ export class DetrFeatureExtractor extends ImageFeatureExtractor {
|
|
|
302
317
|
post_process_object_detection(outputs: {
|
|
303
318
|
logits: Tensor;
|
|
304
319
|
pred_boxes: Tensor;
|
|
305
|
-
}, threshold?: number, target_sizes?: number
|
|
306
|
-
/**
|
|
307
|
-
* Binarize the given masks using `object_mask_threshold`, it returns the associated values of `masks`, `scores` and `labels`.
|
|
308
|
-
* @param {Tensor} class_logits The class logits.
|
|
309
|
-
* @param {Tensor} mask_logits The mask logits.
|
|
310
|
-
* @param {number} object_mask_threshold A number between 0 and 1 used to binarize the masks.
|
|
311
|
-
* @param {number} num_labels The number of labels.
|
|
312
|
-
* @returns {[Tensor[], number[], number[]]} The binarized masks, the scores, and the labels.
|
|
313
|
-
*/
|
|
314
|
-
remove_low_and_no_objects(class_logits: Tensor, mask_logits: Tensor, object_mask_threshold: number, num_labels: number): [Tensor[], number[], number[]];
|
|
315
|
-
/**
|
|
316
|
-
* Checks whether the segment is valid or not.
|
|
317
|
-
* @param {Int32Array} mask_labels Labels for each pixel in the mask.
|
|
318
|
-
* @param {Tensor[]} mask_probs Probabilities for each pixel in the masks.
|
|
319
|
-
* @param {number} k The class id of the segment.
|
|
320
|
-
* @param {number} mask_threshold The mask threshold.
|
|
321
|
-
* @param {number} overlap_mask_area_threshold The overlap mask area threshold.
|
|
322
|
-
* @returns {[boolean, number[]]} Whether the segment is valid or not, and the indices of the valid labels.
|
|
323
|
-
*/
|
|
324
|
-
check_segment_validity(mask_labels: Int32Array, mask_probs: Tensor[], k: number, mask_threshold?: number, overlap_mask_area_threshold?: number): [boolean, number[]];
|
|
325
|
-
/**
|
|
326
|
-
* Computes the segments.
|
|
327
|
-
* @param {Tensor[]} mask_probs The mask probabilities.
|
|
328
|
-
* @param {number[]} pred_scores The predicted scores.
|
|
329
|
-
* @param {number[]} pred_labels The predicted labels.
|
|
330
|
-
* @param {number} mask_threshold The mask threshold.
|
|
331
|
-
* @param {number} overlap_mask_area_threshold The overlap mask area threshold.
|
|
332
|
-
* @param {Set<number>} label_ids_to_fuse The label ids to fuse.
|
|
333
|
-
* @param {number[]} target_size The target size of the image.
|
|
334
|
-
* @returns {[Tensor, Array<{id: number, label_id: number, score: number}>]} The computed segments.
|
|
335
|
-
*/
|
|
336
|
-
compute_segments(mask_probs: Tensor[], pred_scores: number[], pred_labels: number[], mask_threshold: number, overlap_mask_area_threshold: number, label_ids_to_fuse?: Set<number>, target_size?: number[]): [Tensor, Array<{
|
|
337
|
-
id: number;
|
|
338
|
-
label_id: number;
|
|
339
|
-
score: number;
|
|
340
|
-
}>];
|
|
320
|
+
}, threshold?: number, target_sizes?: [number, number][], is_zero_shot?: boolean): any[];
|
|
341
321
|
/**
|
|
342
322
|
* Post-process the model output to generate the final panoptic segmentation.
|
|
343
323
|
* @param {*} outputs The model output to post process
|
|
@@ -345,17 +325,38 @@ export class DetrFeatureExtractor extends ImageFeatureExtractor {
|
|
|
345
325
|
* @param {number} [mask_threshold=0.5] Threshold to use when turning the predicted masks into binary values.
|
|
346
326
|
* @param {number} [overlap_mask_area_threshold=0.8] The overlap mask area threshold to merge or discard small disconnected parts within each binary instance mask.
|
|
347
327
|
* @param {Set<number>} [label_ids_to_fuse=null] The labels in this state will have all their instances be fused together.
|
|
348
|
-
* @param {number
|
|
328
|
+
* @param {[number, number][]} [target_sizes=null] The target sizes to resize the masks to.
|
|
349
329
|
* @returns {Array<{ segmentation: Tensor, segments_info: Array<{id: number, label_id: number, score: number}>}>}
|
|
350
330
|
*/
|
|
351
|
-
post_process_panoptic_segmentation(outputs: any, threshold?: number, mask_threshold?: number, overlap_mask_area_threshold?: number, label_ids_to_fuse?: Set<number>, target_sizes?: number
|
|
331
|
+
post_process_panoptic_segmentation(outputs: any, threshold?: number, mask_threshold?: number, overlap_mask_area_threshold?: number, label_ids_to_fuse?: Set<number>, target_sizes?: [number, number][]): {
|
|
352
332
|
segmentation: Tensor;
|
|
353
|
-
segments_info:
|
|
333
|
+
segments_info: {
|
|
354
334
|
id: number;
|
|
355
335
|
label_id: number;
|
|
356
336
|
score: number;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
337
|
+
}[];
|
|
338
|
+
}[];
|
|
339
|
+
post_process_instance_segmentation(): void;
|
|
340
|
+
}
|
|
341
|
+
export class MaskFormerFeatureExtractor extends ImageFeatureExtractor {
|
|
342
|
+
/**
|
|
343
|
+
* Post-process the model output to generate the final panoptic segmentation.
|
|
344
|
+
* @param {*} outputs The model output to post process
|
|
345
|
+
* @param {number} [threshold=0.5] The probability score threshold to keep predicted instance masks.
|
|
346
|
+
* @param {number} [mask_threshold=0.5] Threshold to use when turning the predicted masks into binary values.
|
|
347
|
+
* @param {number} [overlap_mask_area_threshold=0.8] The overlap mask area threshold to merge or discard small disconnected parts within each binary instance mask.
|
|
348
|
+
* @param {Set<number>} [label_ids_to_fuse=null] The labels in this state will have all their instances be fused together.
|
|
349
|
+
* @param {[number, number][]} [target_sizes=null] The target sizes to resize the masks to.
|
|
350
|
+
* @returns {Array<{ segmentation: Tensor, segments_info: Array<{id: number, label_id: number, score: number}>}>}
|
|
351
|
+
*/
|
|
352
|
+
post_process_panoptic_segmentation(outputs: any, threshold?: number, mask_threshold?: number, overlap_mask_area_threshold?: number, label_ids_to_fuse?: Set<number>, target_sizes?: [number, number][]): {
|
|
353
|
+
segmentation: Tensor;
|
|
354
|
+
segments_info: {
|
|
355
|
+
id: number;
|
|
356
|
+
label_id: number;
|
|
357
|
+
score: number;
|
|
358
|
+
}[];
|
|
359
|
+
}[];
|
|
359
360
|
post_process_instance_segmentation(): void;
|
|
360
361
|
}
|
|
361
362
|
export class YolosFeatureExtractor extends ImageFeatureExtractor {
|
|
@@ -365,7 +366,7 @@ export class YolosFeatureExtractor extends ImageFeatureExtractor {
|
|
|
365
366
|
* @param {Tensor} outputs.logits The logits
|
|
366
367
|
* @param {Tensor} outputs.pred_boxes The predicted boxes.
|
|
367
368
|
* @param {number} [threshold=0.5] The threshold to use for the scores.
|
|
368
|
-
* @param {number
|
|
369
|
+
* @param {[number, number][]} [target_sizes=null] The sizes of the original images.
|
|
369
370
|
* @param {boolean} [is_zero_shot=false] Whether zero-shot object detection was performed.
|
|
370
371
|
* @return {Object[]} An array of objects containing the post-processed outputs.
|
|
371
372
|
* @private
|
|
@@ -373,7 +374,7 @@ export class YolosFeatureExtractor extends ImageFeatureExtractor {
|
|
|
373
374
|
post_process_object_detection(outputs: {
|
|
374
375
|
logits: Tensor;
|
|
375
376
|
pred_boxes: Tensor;
|
|
376
|
-
}, threshold?: number, target_sizes?: number
|
|
377
|
+
}, threshold?: number, target_sizes?: [number, number][], is_zero_shot?: boolean): any[];
|
|
377
378
|
}
|
|
378
379
|
/**
|
|
379
380
|
* @typedef {object} SamImageProcessorResult
|
|
@@ -830,14 +831,17 @@ export class AutoProcessor {
|
|
|
830
831
|
ConvNextFeatureExtractor: typeof ConvNextFeatureExtractor;
|
|
831
832
|
ConvNextImageProcessor: typeof ConvNextImageProcessor;
|
|
832
833
|
SegformerFeatureExtractor: typeof SegformerFeatureExtractor;
|
|
834
|
+
SapiensFeatureExtractor: typeof SapiensFeatureExtractor;
|
|
833
835
|
BitImageProcessor: typeof BitImageProcessor;
|
|
834
836
|
DPTImageProcessor: typeof DPTImageProcessor;
|
|
835
837
|
DPTFeatureExtractor: typeof DPTFeatureExtractor;
|
|
838
|
+
PvtImageProcessor: typeof PvtImageProcessor;
|
|
836
839
|
GLPNFeatureExtractor: typeof GLPNFeatureExtractor;
|
|
837
840
|
BeitFeatureExtractor: typeof BeitFeatureExtractor;
|
|
838
841
|
DeiTFeatureExtractor: typeof DeiTFeatureExtractor;
|
|
839
842
|
DetrFeatureExtractor: typeof DetrFeatureExtractor;
|
|
840
843
|
RTDetrImageProcessor: typeof RTDetrImageProcessor;
|
|
844
|
+
MaskFormerFeatureExtractor: typeof MaskFormerFeatureExtractor;
|
|
841
845
|
YolosFeatureExtractor: typeof YolosFeatureExtractor;
|
|
842
846
|
DonutFeatureExtractor: typeof DonutFeatureExtractor;
|
|
843
847
|
NougatImageProcessor: typeof NougatImageProcessor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processors.d.ts","sourceRoot":"","sources":["../src/processors.js"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"processors.d.ts","sourceRoot":"","sources":["../src/processors.js"],"names":[],"mappings":";;;;AAyjBA;;;;GAIG;AACH;IACI;;;;OAIG;IACH,y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IAAI,MAAM,EAAE,MAAM,CAAC,CACuD;IAErF;;;MAGC;IACD,qBAAwB;IAG5B;;;;OAIG;IACH,wBAHW,MAAM,GAAC,MAAM,EAAE,GACb,MAAM,EAAE,CA6BpB;IAED;;;;;OAKG;IACH,8BAJW,MAAM,QACN,MAAM,cACN,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;MAsC1B;CACJ;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH;IACI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA+CC;IAED;;;;;;;;MAQC;IAED;;;;;;;;;;;;;;OAcG;IACH,sDATW,MAAM,0EAKN,OAAO,gBAAgB,EAAE,iBAAiB,GAExC,QAAQ,SAAS,CAAC,CAuC9B;CACJ;;;;;0BAzlEY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;;;;;kBA2E9B,MAAM;;;;oBACN,aAAa;;;;0BACb,aAAa;;;gBAinBb,MAAM;;yCACP,2BAA2B,GAAG,+BAA+B;;kBAkE5D,MAAM;oBACN,aAAa;0BACb,aAAa;mBACb,MAAM;mBACN,MAAM;kBACN,MAAM;;yBA3tCK,kBAAkB;uBAF2B,mBAAmB"}
|
package/types/tokenizers.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export class TokenizerModel extends TokenizerModel_base {
|
|
|
52
52
|
/**
|
|
53
53
|
* Internal function to call the TokenizerModel instance.
|
|
54
54
|
* @param {string[]} tokens The tokens to encode.
|
|
55
|
-
* @returns {string[]} The encoded
|
|
55
|
+
* @returns {string[]} The encoded tokens.
|
|
56
56
|
*/
|
|
57
57
|
_call(tokens: string[]): string[];
|
|
58
58
|
/**
|
|
@@ -278,6 +278,28 @@ export class PreTrainedTokenizer extends PreTrainedTokenizer_base {
|
|
|
278
278
|
skip_special_tokens?: boolean;
|
|
279
279
|
clean_up_tokenization_spaces?: boolean;
|
|
280
280
|
}): string;
|
|
281
|
+
/**
|
|
282
|
+
* Retrieve the chat template string used for tokenizing chat messages. This template is used
|
|
283
|
+
* internally by the `apply_chat_template` method and can also be used externally to retrieve the model's chat
|
|
284
|
+
* template for better generation tracking.
|
|
285
|
+
*
|
|
286
|
+
* @param {Object} options An optional object containing the following properties:
|
|
287
|
+
* @param {string} [options.chat_template=null]
|
|
288
|
+
* A Jinja template or the name of a template to use for this conversion.
|
|
289
|
+
* It is usually not necessary to pass anything to this argument,
|
|
290
|
+
* as the model's template will be used by default.
|
|
291
|
+
* @param {Object[]} [options.tools=null]
|
|
292
|
+
* A list of tools (callable functions) that will be accessible to the model. If the template does not
|
|
293
|
+
* support function calling, this argument will have no effect. Each tool should be passed as a JSON Schema,
|
|
294
|
+
* giving the name, description and argument types for the tool. See our
|
|
295
|
+
* [chat templating guide](https://huggingface.co/docs/transformers/main/en/chat_templating#automated-function-conversion-for-tool-use)
|
|
296
|
+
* for more information.
|
|
297
|
+
* @returns {string} The chat template string.
|
|
298
|
+
*/
|
|
299
|
+
get_chat_template({ chat_template, tools, }?: {
|
|
300
|
+
chat_template?: string;
|
|
301
|
+
tools?: any[];
|
|
302
|
+
}): string;
|
|
281
303
|
/**
|
|
282
304
|
* Converts a list of message objects with `"role"` and `"content"` keys to a list of token
|
|
283
305
|
* ids. This method is intended for use with chat models, and will read the tokenizer's chat_template attribute to
|
|
@@ -423,7 +445,6 @@ export class MBart50Tokenizer extends MBartTokenizer {
|
|
|
423
445
|
export class RobertaTokenizer extends PreTrainedTokenizer {
|
|
424
446
|
}
|
|
425
447
|
export class BloomTokenizer extends PreTrainedTokenizer {
|
|
426
|
-
constructor(tokenizerJSON: any, tokenizerConfig: any);
|
|
427
448
|
}
|
|
428
449
|
export class LlamaTokenizer extends PreTrainedTokenizer {
|
|
429
450
|
constructor(tokenizerJSON: any, tokenizerConfig: any);
|
|
@@ -571,36 +592,6 @@ export class WhisperTokenizer extends PreTrainedTokenizer {
|
|
|
571
592
|
* @private
|
|
572
593
|
*/
|
|
573
594
|
private mergePunctuations;
|
|
574
|
-
/**
|
|
575
|
-
* Helper function to build translation inputs for a `WhisperTokenizer`,
|
|
576
|
-
* depending on the language, task, and whether to predict timestamp tokens.
|
|
577
|
-
*
|
|
578
|
-
* Used to override the prefix tokens appended to the start of the label sequence.
|
|
579
|
-
*
|
|
580
|
-
* **Example: Get ids for a language**
|
|
581
|
-
* ```javascript
|
|
582
|
-
* // instantiate the tokenizer and set the prefix token to Spanish
|
|
583
|
-
* const tokenizer = await WhisperTokenizer.from_pretrained('Xenova/whisper-tiny');
|
|
584
|
-
* const forced_decoder_ids = tokenizer.get_decoder_prompt_ids({ language: 'spanish' });
|
|
585
|
-
* // [(1, 50262), (2, 50363)]
|
|
586
|
-
* ```
|
|
587
|
-
*
|
|
588
|
-
* @param {Object} options Options to generate the decoder prompt.
|
|
589
|
-
* @param {string} [options.language] The language of the transcription text.
|
|
590
|
-
* The corresponding language id token is appended to the start of the sequence for multilingual
|
|
591
|
-
* speech recognition and speech translation tasks, e.g. for "Spanish" the token "<|es|>" is appended
|
|
592
|
-
* to the start of sequence.
|
|
593
|
-
* @param {string} [options.task] Task identifier to append at the start of sequence (if any).
|
|
594
|
-
* This should be used for mulitlingual fine-tuning, with "transcribe" for speech recognition and
|
|
595
|
-
* "translate" for speech translation.
|
|
596
|
-
* @param {boolean} [options.no_timestamps] Whether to add the <|notimestamps|> token at the start of the sequence.
|
|
597
|
-
* @returns {number[][]} The decoder prompt ids.
|
|
598
|
-
*/
|
|
599
|
-
get_decoder_prompt_ids({ language, task, no_timestamps, }?: {
|
|
600
|
-
language?: string;
|
|
601
|
-
task?: string;
|
|
602
|
-
no_timestamps?: boolean;
|
|
603
|
-
}): number[][];
|
|
604
595
|
}
|
|
605
596
|
export class CodeGenTokenizer extends PreTrainedTokenizer {
|
|
606
597
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenizers.d.ts","sourceRoot":"","sources":["../src/tokenizers.js"],"names":[],"mappings":"
|
|
1
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IAiBI;;;;;;KAMC;IACD,gCAHW,OAAO,CAgCjB;IAnDD;;;;MAIE;IACF,yBAQC;IANG,YAAoB;IAEpB,2BAA2B;IAC3B,cADW,UAAU,EAAE,CACD;IACtB,wBAA8B;IAC9B,kBAAuC;IAyC3C;;;;;MAKE;IACF,cAHU,MAAM,EAAE,GACN,MAAM,CAIjB;IAED;;;;MAIE;IACF,eAHU,MAAM,EAAE,GACN,MAAM,CAIjB;IAED;;;;;;OAMG;IACH,qBAJW,MAAM,EAAE,GACN,MAAM,EAAE,CAKpB;CAEJ;AAtlDD;;;;;GAKG;AACH;IACI;;;;;;;;;;OAUG;IACH;QAR0B,OAAO,EAAtB,MAAM;QACS,EAAE,EAAjB,MAAM;QACW,WAAW,GAA5B,OAAO;QACU,MAAM,GAAvB,OAAO;QACU,MAAM,GAAvB,OAAO;QACU,UAAU,GAA3B,OAAO;QACU,OAAO,GAAxB,OAAO;OAUjB;IAPG,gBAA6B;IAC7B,WAAmB;IACnB,qBAA8C;IAC9C,gBAAoC;IACpC,gBAAoC;IACpC,iBAAsC;IACtC,oBAA2C;CAElD;uBAvRsB,mBAAmB"}
|
package/types/utils/core.d.ts
CHANGED
|
@@ -88,4 +88,11 @@ export function calculateReflectOffset(i: number, w: number): number;
|
|
|
88
88
|
* @returns {Object}
|
|
89
89
|
*/
|
|
90
90
|
export function pick(o: any, props: string[]): any;
|
|
91
|
+
/**
|
|
92
|
+
* Calculate the length of a string, taking multi-byte characters into account.
|
|
93
|
+
* This mimics the behavior of Python's `len` function.
|
|
94
|
+
* @param {string} s The string to calculate the length of.
|
|
95
|
+
* @returns {number} The length of the string.
|
|
96
|
+
*/
|
|
97
|
+
export function len(s: string): number;
|
|
91
98
|
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/utils/core.js"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH;;;;;;;GAOG;AACH,oEAJW,GAAG,GACD,IAAI,CAKhB;AAED;;;;;;GAMG;AACH,kDAGC;AAED;;;;;GAKG;AACH,qCAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;GAMG;AACH,wCAJa,OAAO,CAMnB;AAGD;;;;GAIG;AACH,0CAFa,OAAO,CAInB;AAED;;;;;GAKG;AACH,yCAHW,GAAG,EAAE,GACH,MAAM,EAAE,CAUpB;AAED;;;;;;;GAOG;AACH,mCALW,MAAM,2BAehB;AAED;;;;;GAKG;AACH,qCAHY,OAAO,SAKlB;AAED;;;;;GAKG;AACH,8CAIC;AAED;;;;;GAKG;AACH,0CAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;GAKG;AACH,oCAHW,MAAM,EAAE,OAYlB"}
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/utils/core.js"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH;;;;;;;GAOG;AACH,oEAJW,GAAG,GACD,IAAI,CAKhB;AAED;;;;;;GAMG;AACH,kDAGC;AAED;;;;;GAKG;AACH,qCAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;GAMG;AACH,wCAJa,OAAO,CAMnB;AAGD;;;;GAIG;AACH,0CAFa,OAAO,CAInB;AAED;;;;;GAKG;AACH,yCAHW,GAAG,EAAE,GACH,MAAM,EAAE,CAUpB;AAED;;;;;;;GAOG;AACH,mCALW,MAAM,2BAehB;AAED;;;;;GAKG;AACH,qCAHY,OAAO,SAKlB;AAED;;;;;GAKG;AACH,8CAIC;AAED;;;;;GAKG;AACH,0CAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;GAKG;AACH,oCAHW,MAAM,EAAE,OAYlB;AAED;;;;;GAKG;AACH,uBAHW,MAAM,GACJ,MAAM,CAMlB"}
|
|
@@ -155,7 +155,7 @@ export class TokenLattice {
|
|
|
155
155
|
* @param {number} eosTokenId The end-of-sequence token ID.
|
|
156
156
|
*/
|
|
157
157
|
constructor(sentence: string, bosTokenId: number, eosTokenId: number);
|
|
158
|
-
|
|
158
|
+
chars: string[];
|
|
159
159
|
len: number;
|
|
160
160
|
bosTokenId: number;
|
|
161
161
|
eosTokenId: number;
|
|
@@ -174,7 +174,7 @@ export class TokenLattice {
|
|
|
174
174
|
/**
|
|
175
175
|
* Implements the Viterbi algorithm to compute the most likely sequence of tokens.
|
|
176
176
|
*
|
|
177
|
-
* @returns {TokenLatticeNode[]} The
|
|
177
|
+
* @returns {TokenLatticeNode[]} The most likely sequence of tokens.
|
|
178
178
|
*/
|
|
179
179
|
viterbi(): TokenLatticeNode[];
|
|
180
180
|
/**
|
|
@@ -183,13 +183,13 @@ export class TokenLattice {
|
|
|
183
183
|
*/
|
|
184
184
|
piece(node: TokenLatticeNode): string;
|
|
185
185
|
/**
|
|
186
|
-
* @returns {
|
|
186
|
+
* @returns {string[]} The most likely sequence of tokens.
|
|
187
187
|
*/
|
|
188
|
-
tokens():
|
|
188
|
+
tokens(): string[];
|
|
189
189
|
/**
|
|
190
|
-
* @returns {
|
|
190
|
+
* @returns {number[]} The most likely sequence of token ids.
|
|
191
191
|
*/
|
|
192
|
-
tokenIds():
|
|
192
|
+
tokenIds(): number[];
|
|
193
193
|
}
|
|
194
194
|
/**
|
|
195
195
|
* Represents a node in a character trie.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-structures.d.ts","sourceRoot":"","sources":["../../src/utils/data-structures.js"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAGH;;;;;;;;GAQG;AACH;IAEI;;;OAGG;IACH,gCAFoB,GAAG,QAAE,GAAG,KAAG,OAAO,oBAMrC;IAHG,aAAe;IACf,oBAJgB,GAAG,QAAE,GAAG,KAAG,OAAO,CAIL;IAC7B,iBAAuB;IAG3B;;OAEG;IACH,mBAEC;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,GAAG,CAIf;IAED;;;;OAIG;IACH,gBAHe,GAAG,KACL,MAAM,CAIlB;IAED;;;;OAIG;IACH,eAHW,GAAG,EAAE,GACH,MAAM,CAoBlB;IAED;;;OAGG;IACH,OAFa,GAAG,CAWf;IAED;;;;OAIG;IACH,yBAKC;IAED;;;;;OAKG;IACH,gBAEC;IAED;;;;;OAKG;IACH,cAEC;IAED;;;;;OAKG;IACH,eAEC;IAED;;;;;;OAMG;IACH,iBAEC;IAED;;;;;OAKG;IACH,cAIC;IAED;;;;OAIG;IACH,gBAEC;IAED;;;OAGG;IACH,kBAFW,MAAM,QAOhB;IAED;;;;OAIG;IACH,kBAYC;IAED;;;;OAIG;IACH,kBAEC;CACJ;AAED;;GAEG;AACH;IAEQ,mBAAkC;IAGtC;;;OAGG;IACH,cAFW,MAAM,EAAE,QAMlB;IAED;;;OAGG;IACH,WAFW,MAAM,QAahB;IAED;;;;OAIG;IACH,yBAHW,MAAM,
|
|
1
|
+
{"version":3,"file":"data-structures.d.ts","sourceRoot":"","sources":["../../src/utils/data-structures.js"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAGH;;;;;;;;GAQG;AACH;IAEI;;;OAGG;IACH,gCAFoB,GAAG,QAAE,GAAG,KAAG,OAAO,oBAMrC;IAHG,aAAe;IACf,oBAJgB,GAAG,QAAE,GAAG,KAAG,OAAO,CAIL;IAC7B,iBAAuB;IAG3B;;OAEG;IACH,mBAEC;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,GAAG,CAIf;IAED;;;;OAIG;IACH,gBAHe,GAAG,KACL,MAAM,CAIlB;IAED;;;;OAIG;IACH,eAHW,GAAG,EAAE,GACH,MAAM,CAoBlB;IAED;;;OAGG;IACH,OAFa,GAAG,CAWf;IAED;;;;OAIG;IACH,yBAKC;IAED;;;;;OAKG;IACH,gBAEC;IAED;;;;;OAKG;IACH,cAEC;IAED;;;;;OAKG;IACH,eAEC;IAED;;;;;;OAMG;IACH,iBAEC;IAED;;;;;OAKG;IACH,cAIC;IAED;;;;OAIG;IACH,gBAEC;IAED;;;OAGG;IACH,kBAFW,MAAM,QAOhB;IAED;;;;OAIG;IACH,kBAYC;IAED;;;;OAIG;IACH,kBAEC;CACJ;AAED;;GAEG;AACH;IAEQ,mBAAkC;IAGtC;;;OAGG;IACH,cAFW,MAAM,EAAE,QAMlB;IAED;;;OAGG;IACH,WAFW,MAAM,QAahB;IAED;;;;OAIG;IACH,yBAHW,MAAM,oCAgBhB;CACJ;AAyBD;;GAEG;AACH;IACI;;;;;;OAMG;IACH,sBAJW,MAAM,cACN,MAAM,cACN,MAAM,EAiBhB;IAdG,gBAAiC;IACjC,YAA4B;IAC5B,mBAA4B;IAC5B,mBAA4B;IAC5B,0BAAe;IACf,oBAAgE;IAChE,kBAA8D;IAUlE;;;;;;;OAOG;IACH,YALW,MAAM,UACN,MAAM,SACN,MAAM,WACN,MAAM,QAQhB;IAED;;;;OAIG;IACH,WAFa,gBAAgB,EAAE,CA+C9B;IAED;;;OAGG;IACH,YAHW,gBAAgB,GACd,MAAM,CAIlB;IAED;;OAEG;IACH,UAFa,MAAM,EAAE,CAKpB;IAED;;OAEG;IACH,YAFa,MAAM,EAAE,CAKpB;CACJ;AA9ID;;GAEG;AACH;IAWI;;;OAGG;IACH,kBAFa,YAAY,CAIxB;IAhBD;;;;OAIG;IACH,oBAHW,OAAO,YACP,IAAI,MAAM,EAAE,YAAY,CAAC,EAKnC;IAFG,gBAAoB;IACpB,oCAAwB;CAU/B;AA0HD;IACI;;;;;;;OAOG;IACH,qBANW,MAAM,UACN,MAAM,OACN,MAAM,UACN,MAAM,SACN,MAAM,EAUhB;IAPG,gBAAsB;IACtB,eAAoB;IACpB,YAAc;IACd,eAAoB;IACpB,cAAkB;IAClB,UAAgB;IAChB,uBAAyB;IAG7B;;;OAGG;IACH,SAFa,gBAAgB,CAO5B;CACJ"}
|
package/types/utils/devices.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The list of devices supported by Transformers.js
|
|
3
|
+
*/
|
|
1
4
|
export const DEVICE_TYPES: Readonly<{
|
|
2
|
-
|
|
5
|
+
auto: "auto";
|
|
3
6
|
gpu: "gpu";
|
|
7
|
+
cpu: "cpu";
|
|
4
8
|
wasm: "wasm";
|
|
5
9
|
webgpu: "webgpu";
|
|
10
|
+
cuda: "cuda";
|
|
11
|
+
dml: "dml";
|
|
12
|
+
webnn: "webnn";
|
|
13
|
+
'webnn-npu': "webnn-npu";
|
|
14
|
+
'webnn-gpu': "webnn-gpu";
|
|
15
|
+
'webnn-cpu': "webnn-cpu";
|
|
6
16
|
}>;
|
|
7
17
|
export type DeviceType = keyof typeof DEVICE_TYPES;
|
|
8
18
|
//# sourceMappingURL=devices.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devices.d.ts","sourceRoot":"","sources":["../../src/utils/devices.js"],"names":[],"mappings":"AACA
|
|
1
|
+
{"version":3,"file":"devices.d.ts","sourceRoot":"","sources":["../../src/utils/devices.js"],"names":[],"mappings":"AACA;;GAEG;AACH;;;;;;;;;;;;GAaG;yBAGU,MAAM,mBAAmB"}
|
package/types/utils/dtypes.d.ts
CHANGED
|
@@ -11,10 +11,7 @@ export const DATA_TYPES: Readonly<{
|
|
|
11
11
|
}>;
|
|
12
12
|
/** @typedef {keyof typeof DATA_TYPES} DataType */
|
|
13
13
|
export const DEFAULT_DEVICE_DTYPE_MAPPING: Readonly<{
|
|
14
|
-
cpu: "q8";
|
|
15
|
-
gpu: "fp32";
|
|
16
14
|
wasm: "q8";
|
|
17
|
-
webgpu: "fp32";
|
|
18
15
|
}>;
|
|
19
16
|
/** @type {Record<DataType, string>} */
|
|
20
17
|
export const DEFAULT_DTYPE_SUFFIX_MAPPING: Record<DataType, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dtypes.d.ts","sourceRoot":"","sources":["../../src/utils/dtypes.js"],"names":[],"mappings":"AAeW,0DAcN;AAGL;;;;;;;;;GASG;AACH,kDAAkD;AAElD
|
|
1
|
+
{"version":3,"file":"dtypes.d.ts","sourceRoot":"","sources":["../../src/utils/dtypes.js"],"names":[],"mappings":"AAeW,0DAcN;AAGL;;;;;;;;;GASG;AACH,kDAAkD;AAElD;;GAGG;AAEH,uCAAuC;AACvC,2CADW,OAAO,QAAQ,EAAE,MAAM,CAAC,CAUhC;uBAjBW,MAAM,iBAAiB"}
|
package/types/utils/hub.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export type PretrainedOptions = {
|
|
|
45
45
|
* - The model is a model provided by the library (loaded with the *model id* string of a pretrained model).
|
|
46
46
|
* - The model is loaded by supplying a local directory as `pretrained_model_name_or_path` and a configuration JSON file named *config.json* is found in the directory.
|
|
47
47
|
*/
|
|
48
|
-
config?:
|
|
48
|
+
config?: import('../configs.js').PretrainedConfig;
|
|
49
49
|
/**
|
|
50
50
|
* Path to a directory in which a downloaded pretrained model configuration should be cached if the standard cache should not be used.
|
|
51
51
|
*/
|
|
@@ -89,57 +89,18 @@ export type ModelSpecificPretrainedOptions = {
|
|
|
89
89
|
/**
|
|
90
90
|
* (Optional) User-specified session options passed to the runtime. If not provided, suitable defaults will be chosen.
|
|
91
91
|
*/
|
|
92
|
-
session_options?:
|
|
92
|
+
session_options?: import('onnxruntime-common').InferenceSession.SessionOptions;
|
|
93
93
|
};
|
|
94
94
|
/**
|
|
95
95
|
* Options for loading a pretrained model.
|
|
96
96
|
*/
|
|
97
97
|
export type PretrainedModelOptions = PretrainedOptions & ModelSpecificPretrainedOptions;
|
|
98
|
-
/**
|
|
99
|
-
* @typedef {Object} PretrainedOptions Options for loading a pretrained model.
|
|
100
|
-
* @property {function} [progress_callback=null] If specified, this function will be called during model construction, to provide the user with progress updates.
|
|
101
|
-
* @property {Object} [config=null] Configuration for the model to use instead of an automatically loaded configuration. Configuration can be automatically loaded when:
|
|
102
|
-
* - The model is a model provided by the library (loaded with the *model id* string of a pretrained model).
|
|
103
|
-
* - The model is loaded by supplying a local directory as `pretrained_model_name_or_path` and a configuration JSON file named *config.json* is found in the directory.
|
|
104
|
-
* @property {string} [cache_dir=null] Path to a directory in which a downloaded pretrained model configuration should be cached if the standard cache should not be used.
|
|
105
|
-
* @property {boolean} [local_files_only=false] Whether or not to only look at local files (e.g., not try downloading the model).
|
|
106
|
-
* @property {string} [revision='main'] The specific model version to use. It can be a branch name, a tag name, or a commit id,
|
|
107
|
-
* since we use a git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any identifier allowed by git.
|
|
108
|
-
* NOTE: This setting is ignored for local requests.
|
|
109
|
-
*/
|
|
110
|
-
/**
|
|
111
|
-
* @typedef {Object} ModelSpecificPretrainedOptions Options for loading a pretrained model.
|
|
112
|
-
* @property {string} [subfolder='onnx'] In case the relevant files are located inside a subfolder of the model repo on huggingface.co,
|
|
113
|
-
* you can specify the folder name here.
|
|
114
|
-
* @property {string} [model_file_name=null] If specified, load the model with this name (excluding the .onnx suffix). Currently only valid for encoder- or decoder-only models.
|
|
115
|
-
* @property {import("./devices.js").DeviceType|Record<string, import("./devices.js").DeviceType>} [device=null] The device to run the model on. If not specified, the device will be chosen from the environment settings.
|
|
116
|
-
* @property {import("./dtypes.js").DataType|Record<string, import("./dtypes.js").DataType>} [dtype=null] The data type to use for the model. If not specified, the data type will be chosen from the environment settings.
|
|
117
|
-
* @property {boolean|Record<string, boolean>} [use_external_data_format=false] Whether to load the model using the external data format (used for models >= 2GB in size).
|
|
118
|
-
* @property {Object} [session_options] (Optional) User-specified session options passed to the runtime. If not provided, suitable defaults will be chosen.
|
|
119
|
-
*/
|
|
120
|
-
/**
|
|
121
|
-
* @typedef {PretrainedOptions & ModelSpecificPretrainedOptions} PretrainedModelOptions Options for loading a pretrained model.
|
|
122
|
-
*/
|
|
123
98
|
declare class FileResponse {
|
|
124
99
|
/**
|
|
125
100
|
* Creates a new `FileResponse` object.
|
|
126
101
|
* @param {string|URL} filePath
|
|
127
102
|
*/
|
|
128
103
|
constructor(filePath: string | URL);
|
|
129
|
-
/**
|
|
130
|
-
* Mapping from file extensions to MIME types.
|
|
131
|
-
*/
|
|
132
|
-
_CONTENT_TYPE_MAP: {
|
|
133
|
-
txt: string;
|
|
134
|
-
html: string;
|
|
135
|
-
css: string;
|
|
136
|
-
js: string;
|
|
137
|
-
json: string;
|
|
138
|
-
png: string;
|
|
139
|
-
jpg: string;
|
|
140
|
-
jpeg: string;
|
|
141
|
-
gif: string;
|
|
142
|
-
};
|
|
143
104
|
filePath: string | URL;
|
|
144
105
|
headers: Headers;
|
|
145
106
|
exists: any;
|
package/types/utils/hub.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub.d.ts","sourceRoot":"","sources":["../../src/utils/hub.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hub.d.ts","sourceRoot":"","sources":["../../src/utils/hub.js"],"names":[],"mappings":"AAuLA;;;;;GAKG;AACH,mCAHW,GAAG,GAAC,MAAM,GACR,QAAQ,YAAY,GAAC,QAAQ,CAAC,CAgC1C;AA2GD;;;;;;;;;;;;;;GAcG;AACH,8CAVW,MAAM,YAGN,MAAM,UACN,OAAO,YACP,iBAAiB,GAGf,QAAQ,UAAU,CAAC,CAyO/B;AAED;;;;;;;;;GASG;AACH,wCAPW,MAAM,YACN,MAAM,UACN,OAAO,YACP,iBAAiB,GACf,YAAe,CAc3B;;;;;;;;;;;;;;aAnkBa,OAAO,eAAe,EAAE,gBAAgB;;;;gBAGxC,MAAM;;;;uBACN,OAAO;;;;;;eACP,MAAM;;;;;;;;;;gBAON,MAAM;;;;sBAEN,MAAM;;;;aACN,OAAO,cAAc,EAAE,UAAU,GAAC,OAAO,MAAM,EAAE,OAAO,cAAc,EAAE,UAAU,CAAC;;;;YACnF,OAAO,aAAa,EAAE,QAAQ,GAAC,OAAO,MAAM,EAAE,OAAO,aAAa,EAAE,QAAQ,CAAC;;;;+BAC7E,OAAO,GAAC,OAAO,MAAM,EAAE,OAAO,CAAC;;;;sBAC/B,OAAO,oBAAoB,EAAE,gBAAgB,CAAC,cAAc;;;;;qCAI7D,iBAAiB,GAAG,8BAA8B;AAiB/D;IAEI;;;OAGG;IACH,sBAFW,MAAM,GAAC,GAAG,EA8BpB;IA3BG,uBAAwB;IACxB,iBAA4B;IAE5B,YAAqC;IAEjC,eAAiB;IACjB,mBAAsB;IAQtB,0BAOE;IAQV;;;;OAIG;IACH,qBAFa,IAAI,CAMhB;IAED;;;OAGG;IACH,SAFa,YAAY,CASxB;IAED;;;;;OAKG;IACH,eAHa,QAAQ,WAAW,CAAC,CAMhC;IAED;;;;;OAKG;IACH,QAHa,QAAQ,IAAI,CAAC,CAMzB;IAED;;;;;OAKG;IACH,QAHa,QAAQ,MAAM,CAAC,CAM3B;IAED;;;;;;OAMG;IACH,QAHa,YAAe,CAK3B;CACJ"}
|
package/types/utils/maths.d.ts
CHANGED
|
@@ -62,10 +62,10 @@ export function magnitude(arr: number[]): number;
|
|
|
62
62
|
/**
|
|
63
63
|
* Returns the value and index of the minimum element in an array.
|
|
64
64
|
* @param {number[]|TypedArray} arr array of numbers.
|
|
65
|
-
* @returns {number
|
|
65
|
+
* @returns {[number, number]} the value and index of the minimum element, of the form: [valueOfMin, indexOfMin]
|
|
66
66
|
* @throws {Error} If array is empty.
|
|
67
67
|
*/
|
|
68
|
-
export function min(arr: number[] | TypedArray): number
|
|
68
|
+
export function min(arr: number[] | TypedArray): [number, number];
|
|
69
69
|
/**
|
|
70
70
|
* Returns the value and index of the maximum element in an array.
|
|
71
71
|
* @param {number[]|AnyTypedArray} arr array of numbers.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maths.d.ts","sourceRoot":"","sources":["../../src/utils/maths.js"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH;;;;GAIG;AAEH;;GAEG;AACH,wCAFW,UAAU,yIAqEpB;AAGD;;;;;;;GAOG;AACH,sEAJW,MAAM,EAAE,QACR,MAAM,EAAE,iBAiClB;AAGD;;;;;GAKG;AACH,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AA2C;IAC3C,0BAA2C;IA0B3C,iCAA8C;IAI9C,UAAgC;IAIpC,qDA8CC;IAED,yCAEC;IAED,6CAEC;CACJ"}
|
package/types/utils/tensor.d.ts
CHANGED
|
@@ -153,7 +153,7 @@ export class Tensor {
|
|
|
153
153
|
/** @type {number[]} Dimensions of the tensor. */
|
|
154
154
|
get dims(): number[];
|
|
155
155
|
/** @type {DataType} Type of the tensor. */
|
|
156
|
-
get type(): "string" | "
|
|
156
|
+
get type(): "string" | "float32" | "uint8" | "int8" | "uint16" | "int16" | "int32" | "int64" | "bool" | "float16" | "float64" | "uint32" | "uint64";
|
|
157
157
|
/** @type {DataArray} The data stored in the tensor. */
|
|
158
158
|
get data(): DataArray;
|
|
159
159
|
/** @type {number} The number of elements in the tensor. */
|
|
@@ -238,6 +238,18 @@ export class Tensor {
|
|
|
238
238
|
* @returns {Tensor} Returns `this`.
|
|
239
239
|
*/
|
|
240
240
|
add_(val: number): Tensor;
|
|
241
|
+
/**
|
|
242
|
+
* Return a new Tensor with every element subtracted by a constant.
|
|
243
|
+
* @param {number} val The value to subtract by.
|
|
244
|
+
* @returns {Tensor} The new tensor.
|
|
245
|
+
*/
|
|
246
|
+
sub(val: number): Tensor;
|
|
247
|
+
/**
|
|
248
|
+
* Subtract the tensor by a constant in place.
|
|
249
|
+
* @param {number} val The value to subtract by.
|
|
250
|
+
* @returns {Tensor} Returns `this`.
|
|
251
|
+
*/
|
|
252
|
+
sub_(val: number): Tensor;
|
|
241
253
|
clone(): Tensor;
|
|
242
254
|
slice(...slices: any[]): Tensor;
|
|
243
255
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tensor.d.ts","sourceRoot":"","sources":["../../src/utils/tensor.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tensor.d.ts","sourceRoot":"","sources":["../../src/utils/tensor.js"],"names":[],"mappings":"AA2wBA;;;;;GAKG;AACH,gCAJW,GAAG,gBAED,MAAM,CAKlB;AAGD;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