@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
package/dist/transformers.web.js
CHANGED
|
@@ -4362,7 +4362,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4362
4362
|
|
|
4363
4363
|
|
|
4364
4364
|
|
|
4365
|
-
const VERSION = '3.5.
|
|
4365
|
+
const VERSION = '3.5.2';
|
|
4366
4366
|
|
|
4367
4367
|
// Check if various APIs are available (depends on environment)
|
|
4368
4368
|
const IS_BROWSER_ENV = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
@@ -4591,7 +4591,7 @@ class GenerationConfig {
|
|
|
4591
4591
|
|
|
4592
4592
|
/**
|
|
4593
4593
|
* Number of groups to divide `num_beams` into in order to ensure diversity among different groups of beams.
|
|
4594
|
-
* See [this paper](https://
|
|
4594
|
+
* See [this paper](https://huggingface.co/papers/1610.02424) for more details.
|
|
4595
4595
|
* @type {number}
|
|
4596
4596
|
* @default 1
|
|
4597
4597
|
*/
|
|
@@ -4636,7 +4636,7 @@ class GenerationConfig {
|
|
|
4636
4636
|
/**
|
|
4637
4637
|
* 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.
|
|
4638
4638
|
* 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.
|
|
4639
|
-
* See [this paper](https://
|
|
4639
|
+
* See [this paper](https://huggingface.co/papers/2202.00666) for more details.
|
|
4640
4640
|
* @type {number}
|
|
4641
4641
|
* @default 1.0
|
|
4642
4642
|
*/
|
|
@@ -4645,7 +4645,7 @@ class GenerationConfig {
|
|
|
4645
4645
|
/**
|
|
4646
4646
|
* If set to float strictly between 0 and 1, only tokens with a conditional probability greater than `epsilon_cutoff` will be sampled.
|
|
4647
4647
|
* In the paper, suggested values range from 3e-4 to 9e-4, depending on the size of the model.
|
|
4648
|
-
* See [Truncation Sampling as Language Model Desmoothing](https://
|
|
4648
|
+
* See [Truncation Sampling as Language Model Desmoothing](https://huggingface.co/papers/2210.15191) for more details.
|
|
4649
4649
|
* @type {number}
|
|
4650
4650
|
* @default 0.0
|
|
4651
4651
|
*/
|
|
@@ -4655,7 +4655,7 @@ class GenerationConfig {
|
|
|
4655
4655
|
* Eta sampling is a hybrid of locally typical sampling and epsilon sampling.
|
|
4656
4656
|
* 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)))`.
|
|
4657
4657
|
* 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.
|
|
4658
|
-
* See [Truncation Sampling as Language Model Desmoothing](https://
|
|
4658
|
+
* See [Truncation Sampling as Language Model Desmoothing](https://huggingface.co/papers/2210.15191) for more details.
|
|
4659
4659
|
* @type {number}
|
|
4660
4660
|
* @default 0.0
|
|
4661
4661
|
*/
|
|
@@ -4671,7 +4671,7 @@ class GenerationConfig {
|
|
|
4671
4671
|
|
|
4672
4672
|
/**
|
|
4673
4673
|
* The parameter for repetition penalty. 1.0 means no penalty.
|
|
4674
|
-
* See [this paper](https://
|
|
4674
|
+
* See [this paper](https://huggingface.co/papers/1909.05858) for more details.
|
|
4675
4675
|
* @type {number}
|
|
4676
4676
|
* @default 1.0
|
|
4677
4677
|
*/
|
|
@@ -5344,7 +5344,7 @@ class NoRepeatNGramLogitsProcessor extends LogitsProcessor {
|
|
|
5344
5344
|
* This penalty is applied at most once per token. Note that, for decoder-only models like most LLMs,
|
|
5345
5345
|
* the considered tokens include the prompt.
|
|
5346
5346
|
*
|
|
5347
|
-
* In the original [paper](https://
|
|
5347
|
+
* In the original [paper](https://huggingface.co/papers/1909.05858), the authors suggest the use of a
|
|
5348
5348
|
* penalty of around 1.2 to achieve a good balance between truthful generation and lack of repetition.
|
|
5349
5349
|
* To penalize and reduce repetition, use `penalty` values above 1.0, where a higher value penalizes
|
|
5350
5350
|
* more strongly. To reward and encourage repetition, use `penalty` values between 0.0 and 1.0, where
|
|
@@ -5514,7 +5514,7 @@ class NoBadWordsLogitsProcessor extends LogitsProcessor {
|
|
|
5514
5514
|
* correspond to the unconditional logits (predicted from an empty or 'null' prompt). The processor computes a
|
|
5515
5515
|
* weighted average across the conditional and unconditional logits, parameterised by the `guidance_scale`.
|
|
5516
5516
|
*
|
|
5517
|
-
* See [the paper](https://
|
|
5517
|
+
* See [the paper](https://huggingface.co/papers/2306.05284) for more information.
|
|
5518
5518
|
*/
|
|
5519
5519
|
class ClassifierFreeGuidanceLogitsProcessor extends LogitsProcessor {
|
|
5520
5520
|
|
|
@@ -6281,7 +6281,11 @@ class WhisperTextStreamer extends TextStreamer {
|
|
|
6281
6281
|
this.on_chunk_start?.(time);
|
|
6282
6282
|
}
|
|
6283
6283
|
this.waiting_for_timestamp = !this.waiting_for_timestamp; // Toggle
|
|
6284
|
-
|
|
6284
|
+
|
|
6285
|
+
// NOTE: Timestamp tokens should not be printed. Although, since they
|
|
6286
|
+
// aren't classified as "special tokens", we need to handle them here.
|
|
6287
|
+
this.token_callback_function?.(tokens);
|
|
6288
|
+
return;
|
|
6285
6289
|
}
|
|
6286
6290
|
}
|
|
6287
6291
|
return super.put(value);
|
|
@@ -13863,7 +13867,7 @@ class DecisionTransformerPreTrainedModel extends PreTrainedModel { }
|
|
|
13863
13867
|
|
|
13864
13868
|
/**
|
|
13865
13869
|
* The model builds upon the GPT2 architecture to perform autoregressive prediction of actions in an offline RL setting.
|
|
13866
|
-
* Refer to the paper for more details: https://
|
|
13870
|
+
* Refer to the paper for more details: https://huggingface.co/papers/2106.01345
|
|
13867
13871
|
*/
|
|
13868
13872
|
class DecisionTransformerModel extends DecisionTransformerPreTrainedModel { }
|
|
13869
13873
|
|
|
@@ -22283,7 +22287,7 @@ class AutomaticSpeechRecognitionPipeline extends (/** @type {new (options: TextA
|
|
|
22283
22287
|
for (const aud of preparedAudios) {
|
|
22284
22288
|
const inputs = await this.processor(aud);
|
|
22285
22289
|
|
|
22286
|
-
// According to the [paper](https://
|
|
22290
|
+
// According to the [paper](https://huggingface.co/papers/2410.15608):
|
|
22287
22291
|
// "We use greedy decoding, with a heuristic limit of 6 output tokens
|
|
22288
22292
|
// per second of audio to avoid repeated output sequences."
|
|
22289
22293
|
const max_new_tokens = Math.floor(aud.length / sampling_rate) * 6;
|
|
@@ -24319,15 +24323,19 @@ class TokenizerModel extends _utils_generic_js__WEBPACK_IMPORTED_MODULE_0__.Call
|
|
|
24319
24323
|
return new BPE(config);
|
|
24320
24324
|
|
|
24321
24325
|
default:
|
|
24322
|
-
// Some older tokenizers, like `google-t5/t5-small` and `distilbert/distilbert-base-uncased`, do not have a `type` field.
|
|
24326
|
+
// Some older tokenizers, like `google-t5/t5-small`, `openai-community/gpt2`, and `distilbert/distilbert-base-uncased`, do not have a `type` field.
|
|
24323
24327
|
// In this case, we can infer the tokenizer type based on the structure of the `vocab` field and other properties.
|
|
24324
24328
|
if (config.vocab) {
|
|
24325
24329
|
if (Array.isArray(config.vocab)) {
|
|
24326
24330
|
// config.vocab is of type `[string, number][]`
|
|
24327
24331
|
// @ts-ignore
|
|
24328
24332
|
return new Unigram(config, ...args);
|
|
24329
|
-
} else if (
|
|
24330
|
-
|
|
24333
|
+
} else if (Object.hasOwn(config, 'continuing_subword_prefix') && Object.hasOwn(config, 'unk_token')) {
|
|
24334
|
+
if (Object.hasOwn(config, 'merges')) {
|
|
24335
|
+
return new BPE(config);
|
|
24336
|
+
} else {
|
|
24337
|
+
return new WordPieceTokenizer(config);
|
|
24338
|
+
}
|
|
24331
24339
|
} else {
|
|
24332
24340
|
// @ts-ignore
|
|
24333
24341
|
return new LegacyTokenizerModel(config, ...args);
|
|
@@ -27468,7 +27476,7 @@ function _build_translation_inputs(self, raw_inputs, tokenizer_options, generate
|
|
|
27468
27476
|
* between any pair of 200+ languages — including low-resource languages like Asturian,
|
|
27469
27477
|
* Luganda, Urdu and more. It aims to help people communicate with anyone, anywhere,
|
|
27470
27478
|
* regardless of their language preferences. For more information, check out their
|
|
27471
|
-
* [paper](https://
|
|
27479
|
+
* [paper](https://huggingface.co/papers/2207.04672).
|
|
27472
27480
|
*
|
|
27473
27481
|
* For a list of supported languages (along with their language codes),
|
|
27474
27482
|
* @see {@link https://github.com/facebookresearch/flores/blob/main/flores200/README.md#languages-in-flores-200}
|
|
@@ -27499,7 +27507,7 @@ class NllbTokenizer extends PreTrainedTokenizer {
|
|
|
27499
27507
|
* The M2M100Tokenizer class is used to tokenize text for M2M100 ("Many-to-Many") models.
|
|
27500
27508
|
*
|
|
27501
27509
|
* M2M100 is a multilingual encoder-decoder (seq-to-seq) model trained for Many-to-Many
|
|
27502
|
-
* multilingual translation. It was introduced in this [paper](https://
|
|
27510
|
+
* multilingual translation. It was introduced in this [paper](https://huggingface.co/papers/2010.11125)
|
|
27503
27511
|
* and first released in [this](https://github.com/pytorch/fairseq/tree/master/examples/m2m_100) repository.
|
|
27504
27512
|
*
|
|
27505
27513
|
* For a list of supported languages (along with their language codes),
|
|
@@ -35693,6 +35701,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
35693
35701
|
|
|
35694
35702
|
|
|
35695
35703
|
|
|
35704
|
+
|
|
35705
|
+
// Expose common types used across the library for developers to access
|
|
35706
|
+
/**
|
|
35707
|
+
* @typedef {import('./utils/hub.js').PretrainedModelOptions} PretrainedModelOptions
|
|
35708
|
+
* @typedef {import('./base/processing_utils.js').PretrainedProcessorOptions} PretrainedProcessorOptions
|
|
35709
|
+
* @typedef {import('./utils/dtypes.js').DataType} DataType
|
|
35710
|
+
* @typedef {import('./utils/devices.js').DeviceType} DeviceType
|
|
35711
|
+
*/
|
|
35696
35712
|
|
|
35697
35713
|
})();
|
|
35698
35714
|
|