@huggingface/transformers 3.5.1 → 3.5.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 +128 -128
- package/dist/transformers.js +32 -16
- package/dist/transformers.js.map +1 -1
- package/dist/transformers.min.js +1 -1
- package/dist/transformers.min.js.map +1 -1
- package/dist/transformers.node.cjs +32 -16
- package/dist/transformers.node.cjs.map +1 -1
- package/dist/transformers.node.min.cjs +1 -1
- package/dist/transformers.node.min.cjs.map +1 -1
- package/dist/transformers.node.min.mjs +1 -1
- package/dist/transformers.node.min.mjs.map +1 -1
- package/dist/transformers.node.mjs +32 -16
- package/dist/transformers.node.mjs.map +1 -1
- package/dist/transformers.web.js +32 -16
- package/dist/transformers.web.js.map +1 -1
- package/dist/transformers.web.min.js +1 -1
- package/dist/transformers.web.min.js.map +1 -1
- package/package.json +1 -1
- package/src/env.js +1 -1
- package/src/generation/configuration_utils.js +5 -5
- package/src/generation/logits_process.js +2 -2
- package/src/generation/streamers.js +5 -1
- package/src/models.js +1 -1
- package/src/pipelines.js +1 -1
- package/src/tokenizers.js +9 -5
- package/src/transformers.js +8 -0
- package/types/generation/configuration_utils.d.ts +5 -5
- package/types/generation/logits_process.d.ts +2 -2
- package/types/generation/streamers.d.ts.map +1 -1
- package/types/models.d.ts +1 -1
- package/types/tokenizers.d.ts +2 -2
- package/types/tokenizers.d.ts.map +1 -1
- package/types/transformers.d.ts +4 -0
- package/types/transformers.d.ts.map +1 -1
|
@@ -4355,7 +4355,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4355
4355
|
|
|
4356
4356
|
|
|
4357
4357
|
|
|
4358
|
-
const VERSION = '3.5.
|
|
4358
|
+
const VERSION = '3.5.2';
|
|
4359
4359
|
|
|
4360
4360
|
// Check if various APIs are available (depends on environment)
|
|
4361
4361
|
const IS_BROWSER_ENV = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
@@ -4585,7 +4585,7 @@ class GenerationConfig {
|
|
|
4585
4585
|
|
|
4586
4586
|
/**
|
|
4587
4587
|
* Number of groups to divide `num_beams` into in order to ensure diversity among different groups of beams.
|
|
4588
|
-
* See [this paper](https://
|
|
4588
|
+
* See [this paper](https://huggingface.co/papers/1610.02424) for more details.
|
|
4589
4589
|
* @type {number}
|
|
4590
4590
|
* @default 1
|
|
4591
4591
|
*/
|
|
@@ -4630,7 +4630,7 @@ class GenerationConfig {
|
|
|
4630
4630
|
/**
|
|
4631
4631
|
* Local typicality measures how similar the conditional probability of predicting a target token next is to the expected conditional probability of predicting a random token next, given the partial text already generated.
|
|
4632
4632
|
* If set to float < 1, the smallest set of the most locally typical tokens with probabilities that add up to `typical_p` or higher are kept for generation.
|
|
4633
|
-
* See [this paper](https://
|
|
4633
|
+
* See [this paper](https://huggingface.co/papers/2202.00666) for more details.
|
|
4634
4634
|
* @type {number}
|
|
4635
4635
|
* @default 1.0
|
|
4636
4636
|
*/
|
|
@@ -4639,7 +4639,7 @@ class GenerationConfig {
|
|
|
4639
4639
|
/**
|
|
4640
4640
|
* If set to float strictly between 0 and 1, only tokens with a conditional probability greater than `epsilon_cutoff` will be sampled.
|
|
4641
4641
|
* In the paper, suggested values range from 3e-4 to 9e-4, depending on the size of the model.
|
|
4642
|
-
* See [Truncation Sampling as Language Model Desmoothing](https://
|
|
4642
|
+
* See [Truncation Sampling as Language Model Desmoothing](https://huggingface.co/papers/2210.15191) for more details.
|
|
4643
4643
|
* @type {number}
|
|
4644
4644
|
* @default 0.0
|
|
4645
4645
|
*/
|
|
@@ -4649,7 +4649,7 @@ class GenerationConfig {
|
|
|
4649
4649
|
* Eta sampling is a hybrid of locally typical sampling and epsilon sampling.
|
|
4650
4650
|
* If set to float strictly between 0 and 1, a token is only considered if it is greater than either `eta_cutoff` or `sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits)))`.
|
|
4651
4651
|
* The latter term is intuitively the expected next token probability, scaled by `sqrt(eta_cutoff)`. In the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model.
|
|
4652
|
-
* See [Truncation Sampling as Language Model Desmoothing](https://
|
|
4652
|
+
* See [Truncation Sampling as Language Model Desmoothing](https://huggingface.co/papers/2210.15191) for more details.
|
|
4653
4653
|
* @type {number}
|
|
4654
4654
|
* @default 0.0
|
|
4655
4655
|
*/
|
|
@@ -4665,7 +4665,7 @@ class GenerationConfig {
|
|
|
4665
4665
|
|
|
4666
4666
|
/**
|
|
4667
4667
|
* The parameter for repetition penalty. 1.0 means no penalty.
|
|
4668
|
-
* See [this paper](https://
|
|
4668
|
+
* See [this paper](https://huggingface.co/papers/1909.05858) for more details.
|
|
4669
4669
|
* @type {number}
|
|
4670
4670
|
* @default 1.0
|
|
4671
4671
|
*/
|
|
@@ -5339,7 +5339,7 @@ class NoRepeatNGramLogitsProcessor extends LogitsProcessor {
|
|
|
5339
5339
|
* This penalty is applied at most once per token. Note that, for decoder-only models like most LLMs,
|
|
5340
5340
|
* the considered tokens include the prompt.
|
|
5341
5341
|
*
|
|
5342
|
-
* In the original [paper](https://
|
|
5342
|
+
* In the original [paper](https://huggingface.co/papers/1909.05858), the authors suggest the use of a
|
|
5343
5343
|
* penalty of around 1.2 to achieve a good balance between truthful generation and lack of repetition.
|
|
5344
5344
|
* To penalize and reduce repetition, use `penalty` values above 1.0, where a higher value penalizes
|
|
5345
5345
|
* more strongly. To reward and encourage repetition, use `penalty` values between 0.0 and 1.0, where
|
|
@@ -5509,7 +5509,7 @@ class NoBadWordsLogitsProcessor extends LogitsProcessor {
|
|
|
5509
5509
|
* correspond to the unconditional logits (predicted from an empty or 'null' prompt). The processor computes a
|
|
5510
5510
|
* weighted average across the conditional and unconditional logits, parameterised by the `guidance_scale`.
|
|
5511
5511
|
*
|
|
5512
|
-
* See [the paper](https://
|
|
5512
|
+
* See [the paper](https://huggingface.co/papers/2306.05284) for more information.
|
|
5513
5513
|
*/
|
|
5514
5514
|
class ClassifierFreeGuidanceLogitsProcessor extends LogitsProcessor {
|
|
5515
5515
|
|
|
@@ -6279,7 +6279,11 @@ class WhisperTextStreamer extends TextStreamer {
|
|
|
6279
6279
|
this.on_chunk_start?.(time);
|
|
6280
6280
|
}
|
|
6281
6281
|
this.waiting_for_timestamp = !this.waiting_for_timestamp; // Toggle
|
|
6282
|
-
|
|
6282
|
+
|
|
6283
|
+
// NOTE: Timestamp tokens should not be printed. Although, since they
|
|
6284
|
+
// aren't classified as "special tokens", we need to handle them here.
|
|
6285
|
+
this.token_callback_function?.(tokens);
|
|
6286
|
+
return;
|
|
6283
6287
|
}
|
|
6284
6288
|
}
|
|
6285
6289
|
return super.put(value);
|
|
@@ -13862,7 +13866,7 @@ class DecisionTransformerPreTrainedModel extends PreTrainedModel { }
|
|
|
13862
13866
|
|
|
13863
13867
|
/**
|
|
13864
13868
|
* The model builds upon the GPT2 architecture to perform autoregressive prediction of actions in an offline RL setting.
|
|
13865
|
-
* Refer to the paper for more details: https://
|
|
13869
|
+
* Refer to the paper for more details: https://huggingface.co/papers/2106.01345
|
|
13866
13870
|
*/
|
|
13867
13871
|
class DecisionTransformerModel extends DecisionTransformerPreTrainedModel { }
|
|
13868
13872
|
|
|
@@ -22362,7 +22366,7 @@ class AutomaticSpeechRecognitionPipeline extends (/** @type {new (options: TextA
|
|
|
22362
22366
|
for (const aud of preparedAudios) {
|
|
22363
22367
|
const inputs = await this.processor(aud);
|
|
22364
22368
|
|
|
22365
|
-
// According to the [paper](https://
|
|
22369
|
+
// According to the [paper](https://huggingface.co/papers/2410.15608):
|
|
22366
22370
|
// "We use greedy decoding, with a heuristic limit of 6 output tokens
|
|
22367
22371
|
// per second of audio to avoid repeated output sequences."
|
|
22368
22372
|
const max_new_tokens = Math.floor(aud.length / sampling_rate) * 6;
|
|
@@ -24399,15 +24403,19 @@ class TokenizerModel extends _utils_generic_js__WEBPACK_IMPORTED_MODULE_0__.Call
|
|
|
24399
24403
|
return new BPE(config);
|
|
24400
24404
|
|
|
24401
24405
|
default:
|
|
24402
|
-
// Some older tokenizers, like `google-t5/t5-small` and `distilbert/distilbert-base-uncased`, do not have a `type` field.
|
|
24406
|
+
// Some older tokenizers, like `google-t5/t5-small`, `openai-community/gpt2`, and `distilbert/distilbert-base-uncased`, do not have a `type` field.
|
|
24403
24407
|
// In this case, we can infer the tokenizer type based on the structure of the `vocab` field and other properties.
|
|
24404
24408
|
if (config.vocab) {
|
|
24405
24409
|
if (Array.isArray(config.vocab)) {
|
|
24406
24410
|
// config.vocab is of type `[string, number][]`
|
|
24407
24411
|
// @ts-ignore
|
|
24408
24412
|
return new Unigram(config, ...args);
|
|
24409
|
-
} else if (
|
|
24410
|
-
|
|
24413
|
+
} else if (Object.hasOwn(config, 'continuing_subword_prefix') && Object.hasOwn(config, 'unk_token')) {
|
|
24414
|
+
if (Object.hasOwn(config, 'merges')) {
|
|
24415
|
+
return new BPE(config);
|
|
24416
|
+
} else {
|
|
24417
|
+
return new WordPieceTokenizer(config);
|
|
24418
|
+
}
|
|
24411
24419
|
} else {
|
|
24412
24420
|
// @ts-ignore
|
|
24413
24421
|
return new LegacyTokenizerModel(config, ...args);
|
|
@@ -27548,7 +27556,7 @@ function _build_translation_inputs(self, raw_inputs, tokenizer_options, generate
|
|
|
27548
27556
|
* between any pair of 200+ languages — including low-resource languages like Asturian,
|
|
27549
27557
|
* Luganda, Urdu and more. It aims to help people communicate with anyone, anywhere,
|
|
27550
27558
|
* regardless of their language preferences. For more information, check out their
|
|
27551
|
-
* [paper](https://
|
|
27559
|
+
* [paper](https://huggingface.co/papers/2207.04672).
|
|
27552
27560
|
*
|
|
27553
27561
|
* For a list of supported languages (along with their language codes),
|
|
27554
27562
|
* @see {@link https://github.com/facebookresearch/flores/blob/main/flores200/README.md#languages-in-flores-200}
|
|
@@ -27579,7 +27587,7 @@ class NllbTokenizer extends PreTrainedTokenizer {
|
|
|
27579
27587
|
* The M2M100Tokenizer class is used to tokenize text for M2M100 ("Many-to-Many") models.
|
|
27580
27588
|
*
|
|
27581
27589
|
* M2M100 is a multilingual encoder-decoder (seq-to-seq) model trained for Many-to-Many
|
|
27582
|
-
* multilingual translation. It was introduced in this [paper](https://
|
|
27590
|
+
* multilingual translation. It was introduced in this [paper](https://huggingface.co/papers/2010.11125)
|
|
27583
27591
|
* and first released in [this](https://github.com/pytorch/fairseq/tree/master/examples/m2m_100) repository.
|
|
27584
27592
|
*
|
|
27585
27593
|
* For a list of supported languages (along with their language codes),
|
|
@@ -35786,6 +35794,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
35786
35794
|
|
|
35787
35795
|
|
|
35788
35796
|
|
|
35797
|
+
|
|
35798
|
+
// Expose common types used across the library for developers to access
|
|
35799
|
+
/**
|
|
35800
|
+
* @typedef {import('./utils/hub.js').PretrainedModelOptions} PretrainedModelOptions
|
|
35801
|
+
* @typedef {import('./base/processing_utils.js').PretrainedProcessorOptions} PretrainedProcessorOptions
|
|
35802
|
+
* @typedef {import('./utils/dtypes.js').DataType} DataType
|
|
35803
|
+
* @typedef {import('./utils/devices.js').DeviceType} DeviceType
|
|
35804
|
+
*/
|
|
35789
35805
|
|
|
35790
35806
|
})();
|
|
35791
35807
|
|