@huggingface/transformers 3.0.0-alpha.0

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.
Files changed (96) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +376 -0
  3. package/dist/ort-wasm-simd-threaded.jsep.wasm +0 -0
  4. package/dist/transformers.cjs +30741 -0
  5. package/dist/transformers.cjs.map +1 -0
  6. package/dist/transformers.js +33858 -0
  7. package/dist/transformers.js.map +1 -0
  8. package/dist/transformers.min.cjs +173 -0
  9. package/dist/transformers.min.cjs.map +1 -0
  10. package/dist/transformers.min.js +231 -0
  11. package/dist/transformers.min.js.map +1 -0
  12. package/package.json +92 -0
  13. package/src/backends/onnx.js +151 -0
  14. package/src/configs.js +360 -0
  15. package/src/env.js +152 -0
  16. package/src/generation/configuration_utils.js +381 -0
  17. package/src/generation/logits_process.js +716 -0
  18. package/src/generation/logits_sampler.js +204 -0
  19. package/src/generation/parameters.js +35 -0
  20. package/src/generation/stopping_criteria.js +156 -0
  21. package/src/generation/streamers.js +212 -0
  22. package/src/models/whisper/common_whisper.js +151 -0
  23. package/src/models/whisper/generation_whisper.js +89 -0
  24. package/src/models.js +7028 -0
  25. package/src/ops/registry.js +92 -0
  26. package/src/pipelines.js +3341 -0
  27. package/src/processors.js +2614 -0
  28. package/src/tokenizers.js +4395 -0
  29. package/src/transformers.js +28 -0
  30. package/src/utils/audio.js +704 -0
  31. package/src/utils/constants.js +2 -0
  32. package/src/utils/core.js +149 -0
  33. package/src/utils/data-structures.js +445 -0
  34. package/src/utils/devices.js +11 -0
  35. package/src/utils/dtypes.js +62 -0
  36. package/src/utils/generic.js +35 -0
  37. package/src/utils/hub.js +671 -0
  38. package/src/utils/image.js +745 -0
  39. package/src/utils/maths.js +1050 -0
  40. package/src/utils/tensor.js +1378 -0
  41. package/types/backends/onnx.d.ts +26 -0
  42. package/types/backends/onnx.d.ts.map +1 -0
  43. package/types/configs.d.ts +59 -0
  44. package/types/configs.d.ts.map +1 -0
  45. package/types/env.d.ts +106 -0
  46. package/types/env.d.ts.map +1 -0
  47. package/types/generation/configuration_utils.d.ts +320 -0
  48. package/types/generation/configuration_utils.d.ts.map +1 -0
  49. package/types/generation/logits_process.d.ts +354 -0
  50. package/types/generation/logits_process.d.ts.map +1 -0
  51. package/types/generation/logits_sampler.d.ts +51 -0
  52. package/types/generation/logits_sampler.d.ts.map +1 -0
  53. package/types/generation/parameters.d.ts +47 -0
  54. package/types/generation/parameters.d.ts.map +1 -0
  55. package/types/generation/stopping_criteria.d.ts +81 -0
  56. package/types/generation/stopping_criteria.d.ts.map +1 -0
  57. package/types/generation/streamers.d.ts +81 -0
  58. package/types/generation/streamers.d.ts.map +1 -0
  59. package/types/models/whisper/common_whisper.d.ts +8 -0
  60. package/types/models/whisper/common_whisper.d.ts.map +1 -0
  61. package/types/models/whisper/generation_whisper.d.ts +76 -0
  62. package/types/models/whisper/generation_whisper.d.ts.map +1 -0
  63. package/types/models.d.ts +3845 -0
  64. package/types/models.d.ts.map +1 -0
  65. package/types/ops/registry.d.ts +11 -0
  66. package/types/ops/registry.d.ts.map +1 -0
  67. package/types/pipelines.d.ts +2403 -0
  68. package/types/pipelines.d.ts.map +1 -0
  69. package/types/processors.d.ts +917 -0
  70. package/types/processors.d.ts.map +1 -0
  71. package/types/tokenizers.d.ts +999 -0
  72. package/types/tokenizers.d.ts.map +1 -0
  73. package/types/transformers.d.ts +13 -0
  74. package/types/transformers.d.ts.map +1 -0
  75. package/types/utils/audio.d.ts +130 -0
  76. package/types/utils/audio.d.ts.map +1 -0
  77. package/types/utils/constants.d.ts +2 -0
  78. package/types/utils/constants.d.ts.map +1 -0
  79. package/types/utils/core.d.ts +91 -0
  80. package/types/utils/core.d.ts.map +1 -0
  81. package/types/utils/data-structures.d.ts +236 -0
  82. package/types/utils/data-structures.d.ts.map +1 -0
  83. package/types/utils/devices.d.ts +8 -0
  84. package/types/utils/devices.d.ts.map +1 -0
  85. package/types/utils/dtypes.d.ts +22 -0
  86. package/types/utils/dtypes.d.ts.map +1 -0
  87. package/types/utils/generic.d.ts +11 -0
  88. package/types/utils/generic.d.ts.map +1 -0
  89. package/types/utils/hub.d.ts +191 -0
  90. package/types/utils/hub.d.ts.map +1 -0
  91. package/types/utils/image.d.ts +119 -0
  92. package/types/utils/image.d.ts.map +1 -0
  93. package/types/utils/maths.d.ts +280 -0
  94. package/types/utils/maths.d.ts.map +1 -0
  95. package/types/utils/tensor.d.ts +392 -0
  96. package/types/utils/tensor.d.ts.map +1 -0
@@ -0,0 +1,76 @@
1
+ export class WhisperGenerationConfig extends GenerationConfig {
2
+ /**
3
+ * Whether to return the timestamps with the text. This enables the `WhisperTimestampsLogitsProcessor`.
4
+ * @type {boolean}
5
+ */
6
+ return_timestamps: boolean;
7
+ /**
8
+ * Whether to return token-level timestamps
9
+ * with the text. This can be used with or without the `return_timestamps` option. To get word-level
10
+ * timestamps, use the tokenizer to group the tokens into words.
11
+ * @type {boolean}
12
+ */
13
+ return_token_timestamps: boolean;
14
+ /**
15
+ * The number of audio frames available in this chunk. This is only used generating word-level timestamps.
16
+ * @type {number}
17
+ */
18
+ num_frames: number;
19
+ /**
20
+ * Alignment heads to predict word-level timestamps. This is a list of [layer, head] pairs that
21
+ * select the cross-attention heads that are highly correlated to word-level timing.
22
+ * @type {[number, number][]}
23
+ */
24
+ alignment_heads: [number, number][];
25
+ /**
26
+ * Task to use for generation, either "translate" or "transcribe".
27
+ * @type {string}
28
+ */
29
+ task: string;
30
+ /**
31
+ * Language token to use for generation, can be either in the form of `<|en|>`, `en` or `english`.
32
+ * You can find all the possible language tokens in the `model.generation_config.lang_to_id` dictionary.
33
+ * @type {string}
34
+ */
35
+ language: string;
36
+ /**
37
+ * The id of the `"<|notimestamps|>"` token.
38
+ * @type {number}
39
+ */
40
+ no_timestamps_token_id: number;
41
+ /**
42
+ * Rank-1 list of token IDs created by passing text to [`~WhisperProcessor.get_prompt_ids`] that is
43
+ * provided as a prompt to each chunk. This can be used to provide or "prompt-engineer" a context for
44
+ * transcription, e.g. custom vocabularies or proper nouns to make it more likely to predict those words
45
+ * correctly. It cannot be used in conjunction with `decoder_start_token_id` as it overwrites this value.
46
+ * @type {number[]}
47
+ */
48
+ prompt_ids: number[];
49
+ /**
50
+ * Whether the model is multilingual or not.
51
+ * @type {boolean}
52
+ */
53
+ is_multilingual: boolean;
54
+ /**
55
+ * (Optional) A mapping from language tokens to their corresponding IDs.
56
+ * Only required if the model is multilingual.
57
+ * @type {Record<string, number>|null}
58
+ */
59
+ lang_to_id: Record<string, number> | null;
60
+ /**
61
+ * (Optional) A mapping from task tokens to their corresponding IDs.
62
+ * @type {Record<string, number>|null}
63
+ */
64
+ task_to_id: Record<string, number> | null;
65
+ /**
66
+ * Used to set the maximum value of the initial timestamp. This is used to prevent the model from
67
+ * predicting timestamps that are too far in the future.
68
+ * @type {number}
69
+ */
70
+ max_initial_timestamp_index: number;
71
+ }
72
+ export type WhisperGenerationFunctionParameters = any & {
73
+ generation_config: WhisperGenerationConfig;
74
+ } & WhisperGenerationConfig;
75
+ import { GenerationConfig } from "../../generation/configuration_utils.js";
76
+ //# sourceMappingURL=generation_whisper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generation_whisper.d.ts","sourceRoot":"","sources":["../../../src/models/whisper/generation_whisper.js"],"names":[],"mappings":"AAEA;IAEI;;;OAGG;IACH,mBAFU,OAAO,CAEQ;IAEzB;;;;;OAKG;IACH,yBAFU,OAAO,CAEc;IAE/B;;;OAGG;IACH,YAFU,MAAM,CAEE;IAElB;;;;OAIG;IACH,iBAFU,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAEL;IAEvB;;;OAGG;IACH,MAFU,MAAM,CAEJ;IAEZ;;;;OAIG;IACH,UAFU,MAAM,CAEA;IAEhB;;;OAGG;IACH,wBAFU,MAAM,CAEc;IAE9B;;;;;;OAMG;IACH,YAFU,MAAM,EAAE,CAEA;IAElB;;;OAGG;IACH,iBAFU,OAAO,CAEM;IAEvB;;;;OAIG;IACH,YAFU,OAAO,MAAM,EAAE,MAAM,CAAC,GAAC,IAAI,CAEnB;IAElB;;;OAGG;IACH,YAFU,OAAO,MAAM,EAAE,MAAM,CAAC,GAAC,IAAI,CAEnB;IAElB;;;;OAIG;IACH,6BAFU,MAAM,CAEgB;CACnC;kDAGY,MAAwE;IAAC,iBAAiB,EAAE,uBAAuB,CAAA;CAAC,GAAG,uBAAuB;iCAvF1H,yCAAyC"}