@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.js
CHANGED
|
@@ -8968,7 +8968,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
8968
8968
|
|
|
8969
8969
|
|
|
8970
8970
|
|
|
8971
|
-
const VERSION = '3.5.
|
|
8971
|
+
const VERSION = '3.5.2';
|
|
8972
8972
|
|
|
8973
8973
|
// Check if various APIs are available (depends on environment)
|
|
8974
8974
|
const IS_BROWSER_ENV = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
@@ -9197,7 +9197,7 @@ class GenerationConfig {
|
|
|
9197
9197
|
|
|
9198
9198
|
/**
|
|
9199
9199
|
* Number of groups to divide `num_beams` into in order to ensure diversity among different groups of beams.
|
|
9200
|
-
* See [this paper](https://
|
|
9200
|
+
* See [this paper](https://huggingface.co/papers/1610.02424) for more details.
|
|
9201
9201
|
* @type {number}
|
|
9202
9202
|
* @default 1
|
|
9203
9203
|
*/
|
|
@@ -9242,7 +9242,7 @@ class GenerationConfig {
|
|
|
9242
9242
|
/**
|
|
9243
9243
|
* 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.
|
|
9244
9244
|
* 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.
|
|
9245
|
-
* See [this paper](https://
|
|
9245
|
+
* See [this paper](https://huggingface.co/papers/2202.00666) for more details.
|
|
9246
9246
|
* @type {number}
|
|
9247
9247
|
* @default 1.0
|
|
9248
9248
|
*/
|
|
@@ -9251,7 +9251,7 @@ class GenerationConfig {
|
|
|
9251
9251
|
/**
|
|
9252
9252
|
* If set to float strictly between 0 and 1, only tokens with a conditional probability greater than `epsilon_cutoff` will be sampled.
|
|
9253
9253
|
* In the paper, suggested values range from 3e-4 to 9e-4, depending on the size of the model.
|
|
9254
|
-
* See [Truncation Sampling as Language Model Desmoothing](https://
|
|
9254
|
+
* See [Truncation Sampling as Language Model Desmoothing](https://huggingface.co/papers/2210.15191) for more details.
|
|
9255
9255
|
* @type {number}
|
|
9256
9256
|
* @default 0.0
|
|
9257
9257
|
*/
|
|
@@ -9261,7 +9261,7 @@ class GenerationConfig {
|
|
|
9261
9261
|
* Eta sampling is a hybrid of locally typical sampling and epsilon sampling.
|
|
9262
9262
|
* 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)))`.
|
|
9263
9263
|
* 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.
|
|
9264
|
-
* See [Truncation Sampling as Language Model Desmoothing](https://
|
|
9264
|
+
* See [Truncation Sampling as Language Model Desmoothing](https://huggingface.co/papers/2210.15191) for more details.
|
|
9265
9265
|
* @type {number}
|
|
9266
9266
|
* @default 0.0
|
|
9267
9267
|
*/
|
|
@@ -9277,7 +9277,7 @@ class GenerationConfig {
|
|
|
9277
9277
|
|
|
9278
9278
|
/**
|
|
9279
9279
|
* The parameter for repetition penalty. 1.0 means no penalty.
|
|
9280
|
-
* See [this paper](https://
|
|
9280
|
+
* See [this paper](https://huggingface.co/papers/1909.05858) for more details.
|
|
9281
9281
|
* @type {number}
|
|
9282
9282
|
* @default 1.0
|
|
9283
9283
|
*/
|
|
@@ -9950,7 +9950,7 @@ class NoRepeatNGramLogitsProcessor extends LogitsProcessor {
|
|
|
9950
9950
|
* This penalty is applied at most once per token. Note that, for decoder-only models like most LLMs,
|
|
9951
9951
|
* the considered tokens include the prompt.
|
|
9952
9952
|
*
|
|
9953
|
-
* In the original [paper](https://
|
|
9953
|
+
* In the original [paper](https://huggingface.co/papers/1909.05858), the authors suggest the use of a
|
|
9954
9954
|
* penalty of around 1.2 to achieve a good balance between truthful generation and lack of repetition.
|
|
9955
9955
|
* To penalize and reduce repetition, use `penalty` values above 1.0, where a higher value penalizes
|
|
9956
9956
|
* more strongly. To reward and encourage repetition, use `penalty` values between 0.0 and 1.0, where
|
|
@@ -10120,7 +10120,7 @@ class NoBadWordsLogitsProcessor extends LogitsProcessor {
|
|
|
10120
10120
|
* correspond to the unconditional logits (predicted from an empty or 'null' prompt). The processor computes a
|
|
10121
10121
|
* weighted average across the conditional and unconditional logits, parameterised by the `guidance_scale`.
|
|
10122
10122
|
*
|
|
10123
|
-
* See [the paper](https://
|
|
10123
|
+
* See [the paper](https://huggingface.co/papers/2306.05284) for more information.
|
|
10124
10124
|
*/
|
|
10125
10125
|
class ClassifierFreeGuidanceLogitsProcessor extends LogitsProcessor {
|
|
10126
10126
|
|
|
@@ -10887,7 +10887,11 @@ class WhisperTextStreamer extends TextStreamer {
|
|
|
10887
10887
|
this.on_chunk_start?.(time);
|
|
10888
10888
|
}
|
|
10889
10889
|
this.waiting_for_timestamp = !this.waiting_for_timestamp; // Toggle
|
|
10890
|
-
|
|
10890
|
+
|
|
10891
|
+
// NOTE: Timestamp tokens should not be printed. Although, since they
|
|
10892
|
+
// aren't classified as "special tokens", we need to handle them here.
|
|
10893
|
+
this.token_callback_function?.(tokens);
|
|
10894
|
+
return;
|
|
10891
10895
|
}
|
|
10892
10896
|
}
|
|
10893
10897
|
return super.put(value);
|
|
@@ -18469,7 +18473,7 @@ class DecisionTransformerPreTrainedModel extends PreTrainedModel { }
|
|
|
18469
18473
|
|
|
18470
18474
|
/**
|
|
18471
18475
|
* The model builds upon the GPT2 architecture to perform autoregressive prediction of actions in an offline RL setting.
|
|
18472
|
-
* Refer to the paper for more details: https://
|
|
18476
|
+
* Refer to the paper for more details: https://huggingface.co/papers/2106.01345
|
|
18473
18477
|
*/
|
|
18474
18478
|
class DecisionTransformerModel extends DecisionTransformerPreTrainedModel { }
|
|
18475
18479
|
|
|
@@ -26889,7 +26893,7 @@ class AutomaticSpeechRecognitionPipeline extends (/** @type {new (options: TextA
|
|
|
26889
26893
|
for (const aud of preparedAudios) {
|
|
26890
26894
|
const inputs = await this.processor(aud);
|
|
26891
26895
|
|
|
26892
|
-
// According to the [paper](https://
|
|
26896
|
+
// According to the [paper](https://huggingface.co/papers/2410.15608):
|
|
26893
26897
|
// "We use greedy decoding, with a heuristic limit of 6 output tokens
|
|
26894
26898
|
// per second of audio to avoid repeated output sequences."
|
|
26895
26899
|
const max_new_tokens = Math.floor(aud.length / sampling_rate) * 6;
|
|
@@ -28925,15 +28929,19 @@ class TokenizerModel extends _utils_generic_js__WEBPACK_IMPORTED_MODULE_0__.Call
|
|
|
28925
28929
|
return new BPE(config);
|
|
28926
28930
|
|
|
28927
28931
|
default:
|
|
28928
|
-
// Some older tokenizers, like `google-t5/t5-small` and `distilbert/distilbert-base-uncased`, do not have a `type` field.
|
|
28932
|
+
// Some older tokenizers, like `google-t5/t5-small`, `openai-community/gpt2`, and `distilbert/distilbert-base-uncased`, do not have a `type` field.
|
|
28929
28933
|
// In this case, we can infer the tokenizer type based on the structure of the `vocab` field and other properties.
|
|
28930
28934
|
if (config.vocab) {
|
|
28931
28935
|
if (Array.isArray(config.vocab)) {
|
|
28932
28936
|
// config.vocab is of type `[string, number][]`
|
|
28933
28937
|
// @ts-ignore
|
|
28934
28938
|
return new Unigram(config, ...args);
|
|
28935
|
-
} else if (
|
|
28936
|
-
|
|
28939
|
+
} else if (Object.hasOwn(config, 'continuing_subword_prefix') && Object.hasOwn(config, 'unk_token')) {
|
|
28940
|
+
if (Object.hasOwn(config, 'merges')) {
|
|
28941
|
+
return new BPE(config);
|
|
28942
|
+
} else {
|
|
28943
|
+
return new WordPieceTokenizer(config);
|
|
28944
|
+
}
|
|
28937
28945
|
} else {
|
|
28938
28946
|
// @ts-ignore
|
|
28939
28947
|
return new LegacyTokenizerModel(config, ...args);
|
|
@@ -32074,7 +32082,7 @@ function _build_translation_inputs(self, raw_inputs, tokenizer_options, generate
|
|
|
32074
32082
|
* between any pair of 200+ languages — including low-resource languages like Asturian,
|
|
32075
32083
|
* Luganda, Urdu and more. It aims to help people communicate with anyone, anywhere,
|
|
32076
32084
|
* regardless of their language preferences. For more information, check out their
|
|
32077
|
-
* [paper](https://
|
|
32085
|
+
* [paper](https://huggingface.co/papers/2207.04672).
|
|
32078
32086
|
*
|
|
32079
32087
|
* For a list of supported languages (along with their language codes),
|
|
32080
32088
|
* @see {@link https://github.com/facebookresearch/flores/blob/main/flores200/README.md#languages-in-flores-200}
|
|
@@ -32105,7 +32113,7 @@ class NllbTokenizer extends PreTrainedTokenizer {
|
|
|
32105
32113
|
* The M2M100Tokenizer class is used to tokenize text for M2M100 ("Many-to-Many") models.
|
|
32106
32114
|
*
|
|
32107
32115
|
* M2M100 is a multilingual encoder-decoder (seq-to-seq) model trained for Many-to-Many
|
|
32108
|
-
* multilingual translation. It was introduced in this [paper](https://
|
|
32116
|
+
* multilingual translation. It was introduced in this [paper](https://huggingface.co/papers/2010.11125)
|
|
32109
32117
|
* and first released in [this](https://github.com/pytorch/fairseq/tree/master/examples/m2m_100) repository.
|
|
32110
32118
|
*
|
|
32111
32119
|
* For a list of supported languages (along with their language codes),
|
|
@@ -40315,6 +40323,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
40315
40323
|
|
|
40316
40324
|
|
|
40317
40325
|
|
|
40326
|
+
|
|
40327
|
+
// Expose common types used across the library for developers to access
|
|
40328
|
+
/**
|
|
40329
|
+
* @typedef {import('./utils/hub.js').PretrainedModelOptions} PretrainedModelOptions
|
|
40330
|
+
* @typedef {import('./base/processing_utils.js').PretrainedProcessorOptions} PretrainedProcessorOptions
|
|
40331
|
+
* @typedef {import('./utils/dtypes.js').DataType} DataType
|
|
40332
|
+
* @typedef {import('./utils/devices.js').DeviceType} DeviceType
|
|
40333
|
+
*/
|
|
40318
40334
|
|
|
40319
40335
|
})();
|
|
40320
40336
|
|