@huggingface/transformers 4.0.0-next.1 → 4.0.0-next.10

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 (364) hide show
  1. package/README.md +32 -6
  2. package/dist/ort-wasm-simd-threaded.jsep.mjs +31 -31
  3. package/dist/transformers.js +6050 -3202
  4. package/dist/transformers.min.js +23 -21
  5. package/dist/transformers.node.cjs +6119 -3174
  6. package/dist/transformers.node.min.cjs +25 -23
  7. package/dist/transformers.node.min.mjs +25 -23
  8. package/dist/transformers.node.mjs +6034 -3168
  9. package/dist/transformers.web.js +4255 -1381
  10. package/dist/transformers.web.min.js +23 -19
  11. package/package.json +5 -5
  12. package/src/backends/onnx.js +128 -53
  13. package/src/backends/utils/cacheWasm.js +28 -46
  14. package/src/cache_utils.js +62 -0
  15. package/src/configs.js +123 -23
  16. package/src/env.js +100 -11
  17. package/src/generation/logits_sampler.js +3 -15
  18. package/src/generation/parameters.js +1 -1
  19. package/src/generation/streamers.js +21 -0
  20. package/src/image_processors_utils.js +29 -23
  21. package/src/models/afmoe/modeling_afmoe.js +5 -0
  22. package/src/models/auto/image_processing_auto.js +2 -1
  23. package/src/models/auto/modeling_auto.js +16 -2
  24. package/src/models/auto/tokenization_auto.js +2 -1
  25. package/src/models/chatterbox/modeling_chatterbox.js +1 -1
  26. package/src/models/chmv2/image_processing_chmv2.js +3 -0
  27. package/src/models/chmv2/modeling_chmv2.js +4 -0
  28. package/src/models/clap/feature_extraction_clap.js +2 -1
  29. package/src/models/cohere2/modeling_cohere2.js +5 -0
  30. package/src/models/cohere_asr/feature_extraction_cohere_asr.js +117 -0
  31. package/src/models/cohere_asr/modeling_cohere_asr.js +11 -0
  32. package/src/models/cohere_asr/processing_cohere_asr.js +55 -0
  33. package/src/models/cohere_asr/tokenization_cohere_asr.js +3 -0
  34. package/src/models/deepseek_v3/modeling_deepseek_v3.js +5 -0
  35. package/src/models/detr/image_processing_detr.js +1 -1
  36. package/src/models/eurobert/modeling_eurobert.js +41 -0
  37. package/src/models/feature_extractors.js +3 -0
  38. package/src/models/gemma3/image_processing_gemma3.js +3 -0
  39. package/src/models/gemma3/modeling_gemma3.js +4 -1
  40. package/src/models/gemma3/processing_gemma3.js +45 -0
  41. package/src/models/gemma3n/modeling_gemma3n.js +2 -0
  42. package/src/models/glm46v/image_processing_glm46v.js +12 -0
  43. package/src/models/glm46v/processing_glm46v.js +5 -0
  44. package/src/models/glm_moe_dsa/modeling_glm_moe_dsa.js +5 -0
  45. package/src/models/glm_ocr/modeling_glm_ocr.js +78 -0
  46. package/src/models/granite_speech/feature_extraction_granite_speech.js +58 -0
  47. package/src/models/granite_speech/modeling_granite_speech.js +5 -0
  48. package/src/models/granite_speech/processing_granite_speech.js +62 -0
  49. package/src/models/grounding_dino/image_processing_grounding_dino.js +1 -1
  50. package/src/models/idefics3/modeling_idefics3.js +5 -32
  51. package/src/models/image_processors.js +4 -0
  52. package/src/models/lfm2_vl/image_processing_lfm2_vl.js +305 -0
  53. package/src/models/lfm2_vl/modeling_lfm2_vl.js +13 -0
  54. package/src/models/lfm2_vl/processing_lfm2_vl.js +77 -0
  55. package/src/models/lighton_ocr/modeling_lighton_ocr.js +3 -0
  56. package/src/models/llava/modeling_llava.js +1 -1
  57. package/src/models/marian/tokenization_marian.js +3 -2
  58. package/src/models/mistral3/modeling_mistral3.js +2 -2
  59. package/src/models/mistral4/modeling_mistral4.js +5 -0
  60. package/src/models/modeling_utils.js +283 -300
  61. package/src/models/models.js +26 -1
  62. package/src/models/nemotron_h/modeling_nemotron_h.js +5 -0
  63. package/src/models/olmo_hybrid/modeling_olmo_hybrid.js +5 -0
  64. package/src/models/paligemma/modeling_paligemma.js +2 -25
  65. package/src/models/paligemma/processing_paligemma.js +3 -2
  66. package/src/models/processors.js +8 -0
  67. package/src/models/qwen2_5_vl/modeling_qwen2_5_vl.js +9 -0
  68. package/src/models/qwen2_5_vl/processing_qwen2_5_vl.js +3 -0
  69. package/src/models/qwen2_moe/modeling_qwen2_moe.js +5 -0
  70. package/src/models/qwen2_vl/image_processing_qwen2_vl.js +15 -1
  71. package/src/models/qwen2_vl/modeling_qwen2_vl.js +240 -143
  72. package/src/models/qwen2_vl/processing_qwen2_vl.js +5 -4
  73. package/src/models/qwen3_5/modeling_qwen3_5.js +4 -0
  74. package/src/models/qwen3_5_moe/modeling_qwen3_5_moe.js +4 -0
  75. package/src/models/qwen3_moe/modeling_qwen3_moe.js +5 -0
  76. package/src/models/qwen3_next/modeling_qwen3_next.js +5 -0
  77. package/src/models/qwen3_vl/modeling_qwen3_vl.js +4 -0
  78. package/src/models/qwen3_vl/processing_qwen3_vl.js +3 -0
  79. package/src/models/qwen3_vl_moe/modeling_qwen3_vl_moe.js +4 -0
  80. package/src/models/registry.js +61 -5
  81. package/src/models/sam/image_processing_sam.js +1 -1
  82. package/src/models/session.js +33 -56
  83. package/src/models/smolvlm/modeling_smolvlm.js +7 -0
  84. package/src/models/solar_open/modeling_solar_open.js +5 -0
  85. package/src/models/tokenizers.js +1 -0
  86. package/src/models/ultravox/modeling_ultravox.js +1 -3
  87. package/src/models/voxtral/modeling_voxtral.js +3 -0
  88. package/src/models/voxtral_realtime/feature_extraction_voxtral_realtime.js +71 -0
  89. package/src/models/voxtral_realtime/modeling_voxtral_realtime.js +239 -0
  90. package/src/models/voxtral_realtime/processing_voxtral_realtime.js +113 -0
  91. package/src/models/whisper/feature_extraction_whisper.js +4 -13
  92. package/src/models/whisper/modeling_whisper.js +6 -5
  93. package/src/models/xlm/tokenization_xlm.js +2 -1
  94. package/src/pipelines/automatic-speech-recognition.js +47 -3
  95. package/src/pipelines/document-question-answering.js +1 -1
  96. package/src/pipelines/image-to-text.js +2 -2
  97. package/src/pipelines/index.js +313 -0
  98. package/src/pipelines/summarization.js +1 -1
  99. package/src/pipelines/text-generation.js +5 -1
  100. package/src/pipelines/text-to-audio.js +4 -2
  101. package/src/pipelines/text2text-generation.js +1 -1
  102. package/src/pipelines/translation.js +1 -1
  103. package/src/pipelines/zero-shot-classification.js +3 -2
  104. package/src/pipelines.js +140 -428
  105. package/src/tokenization_utils.js +42 -21
  106. package/src/transformers.js +10 -1
  107. package/src/utils/audio.js +20 -3
  108. package/src/utils/cache/CrossOriginStorageCache.js +251 -0
  109. package/src/utils/cache/FileCache.js +128 -0
  110. package/src/utils/cache/cross-origin-storage.d.ts +38 -0
  111. package/src/utils/cache.js +12 -4
  112. package/src/utils/core.js +23 -1
  113. package/src/utils/devices.js +22 -0
  114. package/src/utils/dtypes.js +55 -0
  115. package/src/utils/hub/{files.js → FileResponse.js} +0 -90
  116. package/src/utils/hub/utils.js +45 -5
  117. package/src/utils/hub.js +67 -23
  118. package/src/utils/image.js +14 -14
  119. package/src/utils/logger.js +67 -0
  120. package/src/utils/lru_cache.js +67 -0
  121. package/src/utils/memoize_promise.js +45 -0
  122. package/src/utils/model-loader.js +35 -17
  123. package/src/utils/model_registry/ModelRegistry.js +382 -0
  124. package/src/utils/model_registry/clear_cache.js +128 -0
  125. package/src/utils/model_registry/get_available_dtypes.js +68 -0
  126. package/src/utils/model_registry/get_file_metadata.js +162 -0
  127. package/src/utils/model_registry/get_files.js +42 -0
  128. package/src/utils/model_registry/get_model_files.js +114 -0
  129. package/src/utils/model_registry/get_pipeline_files.js +44 -0
  130. package/src/utils/model_registry/get_processor_files.js +20 -0
  131. package/src/utils/model_registry/get_tokenizer_files.js +21 -0
  132. package/src/utils/model_registry/is_cached.js +169 -0
  133. package/src/utils/model_registry/resolve_model_type.js +66 -0
  134. package/src/utils/random.js +225 -0
  135. package/src/utils/tensor.js +26 -23
  136. package/src/utils/video.js +2 -2
  137. package/types/backends/onnx.d.ts.map +1 -1
  138. package/types/backends/utils/cacheWasm.d.ts +3 -17
  139. package/types/backends/utils/cacheWasm.d.ts.map +1 -1
  140. package/types/cache_utils.d.ts +29 -0
  141. package/types/cache_utils.d.ts.map +1 -0
  142. package/types/configs.d.ts.map +1 -1
  143. package/types/env.d.ts +60 -27
  144. package/types/env.d.ts.map +1 -1
  145. package/types/generation/logits_sampler.d.ts +2 -2
  146. package/types/generation/logits_sampler.d.ts.map +1 -1
  147. package/types/generation/parameters.d.ts +1 -1
  148. package/types/generation/parameters.d.ts.map +1 -1
  149. package/types/generation/streamers.d.ts +1 -0
  150. package/types/generation/streamers.d.ts.map +1 -1
  151. package/types/image_processors_utils.d.ts +18 -1
  152. package/types/image_processors_utils.d.ts.map +1 -1
  153. package/types/models/afmoe/modeling_afmoe.d.ts +8 -0
  154. package/types/models/afmoe/modeling_afmoe.d.ts.map +1 -0
  155. package/types/models/{ast/modeling_ast.d.ts → audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.d.ts} +1 -1
  156. package/types/models/audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.d.ts.map +1 -0
  157. package/types/models/auto/image_processing_auto.d.ts.map +1 -1
  158. package/types/models/auto/modeling_auto.d.ts +6 -0
  159. package/types/models/auto/modeling_auto.d.ts.map +1 -1
  160. package/types/models/auto/tokenization_auto.d.ts.map +1 -1
  161. package/types/models/chmv2/image_processing_chmv2.d.ts +4 -0
  162. package/types/models/chmv2/image_processing_chmv2.d.ts.map +1 -0
  163. package/types/models/chmv2/modeling_chmv2.d.ts +6 -0
  164. package/types/models/chmv2/modeling_chmv2.d.ts.map +1 -0
  165. package/types/models/clap/feature_extraction_clap.d.ts.map +1 -1
  166. package/types/models/cohere2/modeling_cohere2.d.ts +8 -0
  167. package/types/models/cohere2/modeling_cohere2.d.ts.map +1 -0
  168. package/types/models/cohere_asr/feature_extraction_cohere_asr.d.ts +25 -0
  169. package/types/models/cohere_asr/feature_extraction_cohere_asr.d.ts.map +1 -0
  170. package/types/models/cohere_asr/modeling_cohere_asr.d.ts +9 -0
  171. package/types/models/cohere_asr/modeling_cohere_asr.d.ts.map +1 -0
  172. package/types/models/cohere_asr/processing_cohere_asr.d.ts +27 -0
  173. package/types/models/cohere_asr/processing_cohere_asr.d.ts.map +1 -0
  174. package/types/models/cohere_asr/tokenization_cohere_asr.d.ts +4 -0
  175. package/types/models/cohere_asr/tokenization_cohere_asr.d.ts.map +1 -0
  176. package/types/models/deepseek_v3/modeling_deepseek_v3.d.ts +8 -0
  177. package/types/models/deepseek_v3/modeling_deepseek_v3.d.ts.map +1 -0
  178. package/types/models/detr/image_processing_detr.d.ts +1 -1
  179. package/types/models/eurobert/modeling_eurobert.d.ts +36 -0
  180. package/types/models/eurobert/modeling_eurobert.d.ts.map +1 -0
  181. package/types/models/feature_extractors.d.ts +3 -0
  182. package/types/models/gemma3/image_processing_gemma3.d.ts +4 -0
  183. package/types/models/gemma3/image_processing_gemma3.d.ts.map +1 -0
  184. package/types/models/gemma3/modeling_gemma3.d.ts +4 -1
  185. package/types/models/gemma3/modeling_gemma3.d.ts.map +1 -1
  186. package/types/models/gemma3/processing_gemma3.d.ts +20 -0
  187. package/types/models/gemma3/processing_gemma3.d.ts.map +1 -0
  188. package/types/models/gemma3n/modeling_gemma3n.d.ts +2 -0
  189. package/types/models/gemma3n/modeling_gemma3n.d.ts.map +1 -1
  190. package/types/models/glm46v/image_processing_glm46v.d.ts +4 -0
  191. package/types/models/glm46v/image_processing_glm46v.d.ts.map +1 -0
  192. package/types/models/glm46v/processing_glm46v.d.ts +4 -0
  193. package/types/models/glm46v/processing_glm46v.d.ts.map +1 -0
  194. package/types/models/glm_moe_dsa/modeling_glm_moe_dsa.d.ts +8 -0
  195. package/types/models/glm_moe_dsa/modeling_glm_moe_dsa.d.ts.map +1 -0
  196. package/types/models/glm_ocr/modeling_glm_ocr.d.ts +26 -0
  197. package/types/models/glm_ocr/modeling_glm_ocr.d.ts.map +1 -0
  198. package/types/models/granite_speech/feature_extraction_granite_speech.d.ts +16 -0
  199. package/types/models/granite_speech/feature_extraction_granite_speech.d.ts.map +1 -0
  200. package/types/models/granite_speech/modeling_granite_speech.d.ts +4 -0
  201. package/types/models/granite_speech/modeling_granite_speech.d.ts.map +1 -0
  202. package/types/models/granite_speech/processing_granite_speech.d.ts +19 -0
  203. package/types/models/granite_speech/processing_granite_speech.d.ts.map +1 -0
  204. package/types/models/grounding_dino/image_processing_grounding_dino.d.ts +1 -1
  205. package/types/models/idefics3/modeling_idefics3.d.ts +2 -18
  206. package/types/models/idefics3/modeling_idefics3.d.ts.map +1 -1
  207. package/types/models/image_processors.d.ts +4 -0
  208. package/types/models/lfm2_vl/image_processing_lfm2_vl.d.ts +41 -0
  209. package/types/models/lfm2_vl/image_processing_lfm2_vl.d.ts.map +1 -0
  210. package/types/models/lfm2_vl/modeling_lfm2_vl.d.ts +4 -0
  211. package/types/models/lfm2_vl/modeling_lfm2_vl.d.ts.map +1 -0
  212. package/types/models/lfm2_vl/processing_lfm2_vl.d.ts +18 -0
  213. package/types/models/lfm2_vl/processing_lfm2_vl.d.ts.map +1 -0
  214. package/types/models/lighton_ocr/modeling_lighton_ocr.d.ts +4 -0
  215. package/types/models/lighton_ocr/modeling_lighton_ocr.d.ts.map +1 -0
  216. package/types/models/marian/tokenization_marian.d.ts.map +1 -1
  217. package/types/models/mistral3/modeling_mistral3.d.ts +2 -2
  218. package/types/models/mistral3/modeling_mistral3.d.ts.map +1 -1
  219. package/types/models/mistral4/modeling_mistral4.d.ts +8 -0
  220. package/types/models/mistral4/modeling_mistral4.d.ts.map +1 -0
  221. package/types/models/modeling_utils.d.ts +46 -27
  222. package/types/models/modeling_utils.d.ts.map +1 -1
  223. package/types/models/models.d.ts +26 -1
  224. package/types/models/nemotron_h/modeling_nemotron_h.d.ts +8 -0
  225. package/types/models/nemotron_h/modeling_nemotron_h.d.ts.map +1 -0
  226. package/types/models/olmo_hybrid/modeling_olmo_hybrid.d.ts +8 -0
  227. package/types/models/olmo_hybrid/modeling_olmo_hybrid.d.ts.map +1 -0
  228. package/types/models/paligemma/modeling_paligemma.d.ts +2 -8
  229. package/types/models/paligemma/modeling_paligemma.d.ts.map +1 -1
  230. package/types/models/paligemma/processing_paligemma.d.ts.map +1 -1
  231. package/types/models/processors.d.ts +8 -0
  232. package/types/models/qwen2_5_vl/modeling_qwen2_5_vl.d.ts +7 -0
  233. package/types/models/qwen2_5_vl/modeling_qwen2_5_vl.d.ts.map +1 -0
  234. package/types/models/qwen2_5_vl/processing_qwen2_5_vl.d.ts +4 -0
  235. package/types/models/qwen2_5_vl/processing_qwen2_5_vl.d.ts.map +1 -0
  236. package/types/models/qwen2_moe/modeling_qwen2_moe.d.ts +8 -0
  237. package/types/models/qwen2_moe/modeling_qwen2_moe.d.ts.map +1 -0
  238. package/types/models/qwen2_vl/image_processing_qwen2_vl.d.ts +3 -0
  239. package/types/models/qwen2_vl/image_processing_qwen2_vl.d.ts.map +1 -1
  240. package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts +44 -6
  241. package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts.map +1 -1
  242. package/types/models/qwen2_vl/processing_qwen2_vl.d.ts +1 -0
  243. package/types/models/qwen2_vl/processing_qwen2_vl.d.ts.map +1 -1
  244. package/types/models/qwen3_5/modeling_qwen3_5.d.ts +6 -0
  245. package/types/models/qwen3_5/modeling_qwen3_5.d.ts.map +1 -0
  246. package/types/models/qwen3_5_moe/modeling_qwen3_5_moe.d.ts +7 -0
  247. package/types/models/qwen3_5_moe/modeling_qwen3_5_moe.d.ts.map +1 -0
  248. package/types/models/qwen3_moe/modeling_qwen3_moe.d.ts +8 -0
  249. package/types/models/qwen3_moe/modeling_qwen3_moe.d.ts.map +1 -0
  250. package/types/models/qwen3_next/modeling_qwen3_next.d.ts +8 -0
  251. package/types/models/qwen3_next/modeling_qwen3_next.d.ts.map +1 -0
  252. package/types/models/qwen3_vl/modeling_qwen3_vl.d.ts +7 -0
  253. package/types/models/qwen3_vl/modeling_qwen3_vl.d.ts.map +1 -0
  254. package/types/models/qwen3_vl/processing_qwen3_vl.d.ts +4 -0
  255. package/types/models/qwen3_vl/processing_qwen3_vl.d.ts.map +1 -0
  256. package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts +7 -0
  257. package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts.map +1 -0
  258. package/types/models/registry.d.ts +2 -1
  259. package/types/models/registry.d.ts.map +1 -1
  260. package/types/models/sam/image_processing_sam.d.ts +1 -1
  261. package/types/models/session.d.ts +3 -2
  262. package/types/models/session.d.ts.map +1 -1
  263. package/types/models/smolvlm/modeling_smolvlm.d.ts +8 -0
  264. package/types/models/smolvlm/modeling_smolvlm.d.ts.map +1 -0
  265. package/types/models/solar_open/modeling_solar_open.d.ts +8 -0
  266. package/types/models/solar_open/modeling_solar_open.d.ts.map +1 -0
  267. package/types/models/tokenizers.d.ts +1 -0
  268. package/types/models/ultravox/modeling_ultravox.d.ts +0 -2
  269. package/types/models/ultravox/modeling_ultravox.d.ts.map +1 -1
  270. package/types/models/voxtral/modeling_voxtral.d.ts +4 -0
  271. package/types/models/voxtral/modeling_voxtral.d.ts.map +1 -0
  272. package/types/models/voxtral_realtime/feature_extraction_voxtral_realtime.d.ts +28 -0
  273. package/types/models/voxtral_realtime/feature_extraction_voxtral_realtime.d.ts.map +1 -0
  274. package/types/models/voxtral_realtime/modeling_voxtral_realtime.d.ts +17 -0
  275. package/types/models/voxtral_realtime/modeling_voxtral_realtime.d.ts.map +1 -0
  276. package/types/models/voxtral_realtime/processing_voxtral_realtime.d.ts +44 -0
  277. package/types/models/voxtral_realtime/processing_voxtral_realtime.d.ts.map +1 -0
  278. package/types/models/whisper/feature_extraction_whisper.d.ts.map +1 -1
  279. package/types/models/whisper/modeling_whisper.d.ts.map +1 -1
  280. package/types/models/xlm/tokenization_xlm.d.ts.map +1 -1
  281. package/types/pipelines/automatic-speech-recognition.d.ts +7 -2
  282. package/types/pipelines/automatic-speech-recognition.d.ts.map +1 -1
  283. package/types/pipelines/document-question-answering.d.ts +2 -2
  284. package/types/pipelines/document-question-answering.d.ts.map +1 -1
  285. package/types/pipelines/image-to-text.d.ts +4 -4
  286. package/types/pipelines/image-to-text.d.ts.map +1 -1
  287. package/types/pipelines/index.d.ts +265 -0
  288. package/types/pipelines/index.d.ts.map +1 -0
  289. package/types/pipelines/summarization.d.ts +2 -2
  290. package/types/pipelines/summarization.d.ts.map +1 -1
  291. package/types/pipelines/text-generation.d.ts +7 -3
  292. package/types/pipelines/text-generation.d.ts.map +1 -1
  293. package/types/pipelines/text-to-audio.d.ts.map +1 -1
  294. package/types/pipelines/text2text-generation.d.ts +3 -3
  295. package/types/pipelines/text2text-generation.d.ts.map +1 -1
  296. package/types/pipelines/translation.d.ts +2 -2
  297. package/types/pipelines/translation.d.ts.map +1 -1
  298. package/types/pipelines/zero-shot-classification.d.ts.map +1 -1
  299. package/types/pipelines.d.ts +51 -291
  300. package/types/pipelines.d.ts.map +1 -1
  301. package/types/tokenization_utils.d.ts +44 -26
  302. package/types/tokenization_utils.d.ts.map +1 -1
  303. package/types/transformers.d.ts +7 -1
  304. package/types/transformers.d.ts.map +1 -1
  305. package/types/utils/audio.d.ts +5 -2
  306. package/types/utils/audio.d.ts.map +1 -1
  307. package/types/utils/cache/CrossOriginStorageCache.d.ts +120 -0
  308. package/types/utils/cache/CrossOriginStorageCache.d.ts.map +1 -0
  309. package/types/utils/cache/FileCache.d.ts +39 -0
  310. package/types/utils/cache/FileCache.d.ts.map +1 -0
  311. package/types/utils/cache.d.ts +10 -4
  312. package/types/utils/cache.d.ts.map +1 -1
  313. package/types/utils/core.d.ts +59 -2
  314. package/types/utils/core.d.ts.map +1 -1
  315. package/types/utils/devices.d.ts +15 -0
  316. package/types/utils/devices.d.ts.map +1 -1
  317. package/types/utils/dtypes.d.ts +17 -1
  318. package/types/utils/dtypes.d.ts.map +1 -1
  319. package/types/utils/hub/{files.d.ts → FileResponse.d.ts} +1 -32
  320. package/types/utils/hub/FileResponse.d.ts.map +1 -0
  321. package/types/utils/hub/utils.d.ts +19 -3
  322. package/types/utils/hub/utils.d.ts.map +1 -1
  323. package/types/utils/hub.d.ts +36 -7
  324. package/types/utils/hub.d.ts.map +1 -1
  325. package/types/utils/image.d.ts +1 -1
  326. package/types/utils/logger.d.ts +28 -0
  327. package/types/utils/logger.d.ts.map +1 -0
  328. package/types/utils/lru_cache.d.ts +38 -0
  329. package/types/utils/lru_cache.d.ts.map +1 -0
  330. package/types/utils/memoize_promise.d.ts +14 -0
  331. package/types/utils/memoize_promise.d.ts.map +1 -0
  332. package/types/utils/model-loader.d.ts +15 -0
  333. package/types/utils/model-loader.d.ts.map +1 -1
  334. package/types/utils/model_registry/ModelRegistry.d.ts +298 -0
  335. package/types/utils/model_registry/ModelRegistry.d.ts.map +1 -0
  336. package/types/utils/model_registry/clear_cache.d.ts +74 -0
  337. package/types/utils/model_registry/clear_cache.d.ts.map +1 -0
  338. package/types/utils/model_registry/get_available_dtypes.d.ts +26 -0
  339. package/types/utils/model_registry/get_available_dtypes.d.ts.map +1 -0
  340. package/types/utils/model_registry/get_file_metadata.d.ts +20 -0
  341. package/types/utils/model_registry/get_file_metadata.d.ts.map +1 -0
  342. package/types/utils/model_registry/get_files.d.ts +23 -0
  343. package/types/utils/model_registry/get_files.d.ts.map +1 -0
  344. package/types/utils/model_registry/get_model_files.d.ts +48 -0
  345. package/types/utils/model_registry/get_model_files.d.ts.map +1 -0
  346. package/types/utils/model_registry/get_pipeline_files.d.ts +22 -0
  347. package/types/utils/model_registry/get_pipeline_files.d.ts.map +1 -0
  348. package/types/utils/model_registry/get_processor_files.d.ts +9 -0
  349. package/types/utils/model_registry/get_processor_files.d.ts.map +1 -0
  350. package/types/utils/model_registry/get_tokenizer_files.d.ts +9 -0
  351. package/types/utils/model_registry/get_tokenizer_files.d.ts.map +1 -0
  352. package/types/utils/model_registry/is_cached.d.ts +105 -0
  353. package/types/utils/model_registry/is_cached.d.ts.map +1 -0
  354. package/types/utils/model_registry/resolve_model_type.d.ts +24 -0
  355. package/types/utils/model_registry/resolve_model_type.d.ts.map +1 -0
  356. package/types/utils/random.d.ts +86 -0
  357. package/types/utils/random.d.ts.map +1 -0
  358. package/types/utils/tensor.d.ts.map +1 -1
  359. package/src/utils/data-structures.js +0 -572
  360. package/types/models/ast/modeling_ast.d.ts.map +0 -1
  361. package/types/utils/data-structures.d.ts +0 -294
  362. package/types/utils/data-structures.d.ts.map +0 -1
  363. package/types/utils/hub/files.d.ts.map +0 -1
  364. /package/src/models/{ast/modeling_ast.js → audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.js} +0 -0
@@ -13,6 +13,7 @@
13
13
  * @param {T} task The task defining which pipeline will be returned. Currently accepted tasks are:
14
14
  * - `"audio-classification"`: will return a `AudioClassificationPipeline`.
15
15
  * - `"automatic-speech-recognition"`: will return a `AutomaticSpeechRecognitionPipeline`.
16
+ * - `"background-removal"`: will return a `BackgroundRemovalPipeline`.
16
17
  * - `"depth-estimation"`: will return a `DepthEstimationPipeline`.
17
18
  * - `"document-question-answering"`: will return a `DocumentQuestionAnsweringPipeline`.
18
19
  * - `"feature-extraction"`: will return a `FeatureExtractionPipeline`.
@@ -63,296 +64,55 @@ export type AliasTasks = { [K in AliasType]: InstanceType<(typeof SUPPORTED_TASK
63
64
  * A mapping from all pipeline names and aliases to their corresponding pipeline classes.
64
65
  */
65
66
  export type AllTasks = SupportedTasks & AliasTasks;
66
- import { TextClassificationPipeline } from './pipelines/text-classification.js';
67
- import { TokenClassificationPipeline } from './pipelines/token-classification.js';
68
- import { QuestionAnsweringPipeline } from './pipelines/question-answering.js';
69
- import { FillMaskPipeline } from './pipelines/fill-mask.js';
70
- import { SummarizationPipeline } from './pipelines/summarization.js';
71
- import { TranslationPipeline } from './pipelines/translation.js';
72
- import { Text2TextGenerationPipeline } from './pipelines/text2text-generation.js';
73
- import { TextGenerationPipeline } from './pipelines/text-generation.js';
74
- import { ZeroShotClassificationPipeline } from './pipelines/zero-shot-classification.js';
75
- import { AudioClassificationPipeline } from './pipelines/audio-classification.js';
76
- import { ZeroShotAudioClassificationPipeline } from './pipelines/zero-shot-audio-classification.js';
77
- import { AutomaticSpeechRecognitionPipeline } from './pipelines/automatic-speech-recognition.js';
78
- import { TextToAudioPipeline } from './pipelines/text-to-audio.js';
79
- import { ImageToTextPipeline } from './pipelines/image-to-text.js';
80
- import { ImageClassificationPipeline } from './pipelines/image-classification.js';
81
- import { ImageSegmentationPipeline } from './pipelines/image-segmentation.js';
82
- import { BackgroundRemovalPipeline } from './pipelines/background-removal.js';
83
- import { ZeroShotImageClassificationPipeline } from './pipelines/zero-shot-image-classification.js';
84
- import { ObjectDetectionPipeline } from './pipelines/object-detection.js';
85
- import { ZeroShotObjectDetectionPipeline } from './pipelines/zero-shot-object-detection.js';
86
- import { DocumentQuestionAnsweringPipeline } from './pipelines/document-question-answering.js';
87
- import { ImageToImagePipeline } from './pipelines/image-to-image.js';
88
- import { DepthEstimationPipeline } from './pipelines/depth-estimation.js';
89
- import { FeatureExtractionPipeline } from './pipelines/feature-extraction.js';
90
- import { ImageFeatureExtractionPipeline } from './pipelines/image-feature-extraction.js';
91
- declare const SUPPORTED_TASKS: Readonly<{
92
- 'text-classification': {
93
- tokenizer: typeof AutoTokenizer;
94
- pipeline: typeof TextClassificationPipeline;
95
- model: typeof AutoModelForSequenceClassification;
96
- default: {
97
- model: string;
98
- };
99
- type: string;
100
- };
101
- 'token-classification': {
102
- tokenizer: typeof AutoTokenizer;
103
- pipeline: typeof TokenClassificationPipeline;
104
- model: typeof AutoModelForTokenClassification;
105
- default: {
106
- model: string;
107
- };
108
- type: string;
109
- };
110
- 'question-answering': {
111
- tokenizer: typeof AutoTokenizer;
112
- pipeline: typeof QuestionAnsweringPipeline;
113
- model: typeof AutoModelForQuestionAnswering;
114
- default: {
115
- model: string;
116
- };
117
- type: string;
118
- };
119
- 'fill-mask': {
120
- tokenizer: typeof AutoTokenizer;
121
- pipeline: typeof FillMaskPipeline;
122
- model: typeof AutoModelForMaskedLM;
123
- default: {
124
- model: string;
125
- dtype: string;
126
- };
127
- type: string;
128
- };
129
- summarization: {
130
- tokenizer: typeof AutoTokenizer;
131
- pipeline: typeof SummarizationPipeline;
132
- model: typeof AutoModelForSeq2SeqLM;
133
- default: {
134
- model: string;
135
- };
136
- type: string;
137
- };
138
- translation: {
139
- tokenizer: typeof AutoTokenizer;
140
- pipeline: typeof TranslationPipeline;
141
- model: typeof AutoModelForSeq2SeqLM;
142
- default: {
143
- model: string;
144
- };
145
- type: string;
146
- };
147
- 'text2text-generation': {
148
- tokenizer: typeof AutoTokenizer;
149
- pipeline: typeof Text2TextGenerationPipeline;
150
- model: typeof AutoModelForSeq2SeqLM;
151
- default: {
152
- model: string;
153
- };
154
- type: string;
155
- };
156
- 'text-generation': {
157
- tokenizer: typeof AutoTokenizer;
158
- pipeline: typeof TextGenerationPipeline;
159
- model: typeof AutoModelForCausalLM;
160
- default: {
161
- model: string;
162
- dtype: string;
163
- };
164
- type: string;
165
- };
166
- 'zero-shot-classification': {
167
- tokenizer: typeof AutoTokenizer;
168
- pipeline: typeof ZeroShotClassificationPipeline;
169
- model: typeof AutoModelForSequenceClassification;
170
- default: {
171
- model: string;
172
- };
173
- type: string;
174
- };
175
- 'audio-classification': {
176
- pipeline: typeof AudioClassificationPipeline;
177
- model: typeof AutoModelForAudioClassification;
178
- processor: typeof AutoProcessor;
179
- default: {
180
- model: string;
181
- };
182
- type: string;
183
- };
184
- 'zero-shot-audio-classification': {
185
- tokenizer: typeof AutoTokenizer;
186
- pipeline: typeof ZeroShotAudioClassificationPipeline;
187
- model: typeof AutoModel;
188
- processor: typeof AutoProcessor;
189
- default: {
190
- model: string;
191
- };
192
- type: string;
193
- };
194
- 'automatic-speech-recognition': {
195
- tokenizer: typeof AutoTokenizer;
196
- pipeline: typeof AutomaticSpeechRecognitionPipeline;
197
- model: (typeof AutoModelForSpeechSeq2Seq)[];
198
- processor: typeof AutoProcessor;
199
- default: {
200
- model: string;
201
- };
202
- type: string;
203
- };
204
- 'text-to-audio': {
205
- tokenizer: typeof AutoTokenizer;
206
- pipeline: typeof TextToAudioPipeline;
207
- model: (typeof AutoModelForTextToSpectrogram)[];
208
- processor: (typeof AutoProcessor)[];
209
- default: {
210
- model: string;
211
- dtype: string;
212
- };
213
- type: string;
214
- };
215
- 'image-to-text': {
216
- tokenizer: typeof AutoTokenizer;
217
- pipeline: typeof ImageToTextPipeline;
218
- model: typeof AutoModelForVision2Seq;
219
- processor: typeof AutoProcessor;
220
- default: {
221
- model: string;
222
- };
223
- type: string;
224
- };
225
- 'image-classification': {
226
- pipeline: typeof ImageClassificationPipeline;
227
- model: typeof AutoModelForImageClassification;
228
- processor: typeof AutoProcessor;
229
- default: {
230
- model: string;
231
- };
232
- type: string;
233
- };
234
- 'image-segmentation': {
235
- pipeline: typeof ImageSegmentationPipeline;
236
- model: (typeof AutoModelForImageSegmentation)[];
237
- processor: typeof AutoProcessor;
238
- default: {
239
- model: string;
240
- };
241
- type: string;
242
- };
243
- 'background-removal': {
244
- pipeline: typeof BackgroundRemovalPipeline;
245
- model: (typeof AutoModelForImageSegmentation)[];
246
- processor: typeof AutoProcessor;
247
- default: {
248
- model: string;
249
- };
250
- type: string;
251
- };
252
- 'zero-shot-image-classification': {
253
- tokenizer: typeof AutoTokenizer;
254
- pipeline: typeof ZeroShotImageClassificationPipeline;
255
- model: typeof AutoModel;
256
- processor: typeof AutoProcessor;
257
- default: {
258
- model: string;
259
- };
260
- type: string;
261
- };
262
- 'object-detection': {
263
- pipeline: typeof ObjectDetectionPipeline;
264
- model: typeof AutoModelForObjectDetection;
265
- processor: typeof AutoProcessor;
266
- default: {
267
- model: string;
268
- };
269
- type: string;
270
- };
271
- 'zero-shot-object-detection': {
272
- tokenizer: typeof AutoTokenizer;
273
- pipeline: typeof ZeroShotObjectDetectionPipeline;
274
- model: typeof AutoModelForZeroShotObjectDetection;
275
- processor: typeof AutoProcessor;
276
- default: {
277
- model: string;
278
- };
279
- type: string;
280
- };
281
- 'document-question-answering': {
282
- tokenizer: typeof AutoTokenizer;
283
- pipeline: typeof DocumentQuestionAnsweringPipeline;
284
- model: typeof AutoModelForDocumentQuestionAnswering;
285
- processor: typeof AutoProcessor;
286
- default: {
287
- model: string;
288
- };
289
- type: string;
290
- };
291
- 'image-to-image': {
292
- pipeline: typeof ImageToImagePipeline;
293
- model: typeof AutoModelForImageToImage;
294
- processor: typeof AutoProcessor;
295
- default: {
296
- model: string;
297
- };
298
- type: string;
299
- };
300
- 'depth-estimation': {
301
- pipeline: typeof DepthEstimationPipeline;
302
- model: typeof AutoModelForDepthEstimation;
303
- processor: typeof AutoProcessor;
304
- default: {
305
- model: string;
306
- };
307
- type: string;
308
- };
309
- 'feature-extraction': {
310
- tokenizer: typeof AutoTokenizer;
311
- pipeline: typeof FeatureExtractionPipeline;
312
- model: typeof AutoModel;
313
- default: {
314
- model: string;
315
- dtype: string;
316
- };
317
- type: string;
318
- };
319
- 'image-feature-extraction': {
320
- processor: typeof AutoProcessor;
321
- pipeline: typeof ImageFeatureExtractionPipeline;
322
- model: (typeof AutoModel)[];
323
- default: {
324
- model: string;
325
- dtype: string;
326
- };
327
- type: string;
328
- };
329
- }>;
330
- declare const TASK_ALIASES: Readonly<{
331
- 'sentiment-analysis': "text-classification";
332
- ner: "token-classification";
333
- asr: "automatic-speech-recognition";
334
- 'text-to-speech': "text-to-audio";
335
- embeddings: "feature-extraction";
336
- }>;
337
- import { AutoTokenizer } from './models/auto/tokenization_auto.js';
338
- import { AutoModelForSequenceClassification } from './models/auto/modeling_auto.js';
339
- import { AutoModelForTokenClassification } from './models/auto/modeling_auto.js';
340
- import { AutoModelForQuestionAnswering } from './models/auto/modeling_auto.js';
341
- import { AutoModelForMaskedLM } from './models/auto/modeling_auto.js';
342
- import { AutoModelForSeq2SeqLM } from './models/auto/modeling_auto.js';
343
- import { AutoModelForCausalLM } from './models/auto/modeling_auto.js';
344
- import { AutoModelForAudioClassification } from './models/auto/modeling_auto.js';
345
- import { AutoProcessor } from './models/auto/processing_auto.js';
346
- import { AutoModel } from './models/auto/modeling_auto.js';
347
- import { AutoModelForSpeechSeq2Seq } from './models/auto/modeling_auto.js';
348
- import { AutoModelForTextToSpectrogram } from './models/auto/modeling_auto.js';
349
- import { AutoModelForVision2Seq } from './models/auto/modeling_auto.js';
350
- import { AutoModelForImageClassification } from './models/auto/modeling_auto.js';
351
- import { AutoModelForImageSegmentation } from './models/auto/modeling_auto.js';
352
- import { AutoModelForObjectDetection } from './models/auto/modeling_auto.js';
353
- import { AutoModelForZeroShotObjectDetection } from './models/auto/modeling_auto.js';
354
- import { AutoModelForDocumentQuestionAnswering } from './models/auto/modeling_auto.js';
355
- import { AutoModelForImageToImage } from './models/auto/modeling_auto.js';
356
- import { AutoModelForDepthEstimation } from './models/auto/modeling_auto.js';
67
+ export type FillMaskOutput = import("./pipelines/fill-mask.js").FillMaskOutput;
68
+ export type TextClassificationOutput = import("./pipelines/text-classification.js").TextClassificationOutput;
69
+ export type TokenClassificationOutput = import("./pipelines/token-classification.js").TokenClassificationOutput;
70
+ export type QuestionAnsweringOutput = import("./pipelines/question-answering.js").QuestionAnsweringOutput;
71
+ export type SummarizationOutput = import("./pipelines/summarization.js").SummarizationOutput;
72
+ export type TranslationOutput = import("./pipelines/translation.js").TranslationOutput;
73
+ export type Text2TextGenerationOutput = import("./pipelines/text2text-generation.js").Text2TextGenerationOutput;
74
+ export type TextGenerationOutput = import("./pipelines/text-generation.js").TextGenerationOutput;
75
+ export type TextGenerationStringOutput = import("./pipelines/text-generation.js").TextGenerationStringOutput;
76
+ export type TextGenerationChatOutput = import("./pipelines/text-generation.js").TextGenerationChatOutput;
77
+ export type ZeroShotClassificationOutput = import("./pipelines/zero-shot-classification.js").ZeroShotClassificationOutput;
78
+ export type AudioClassificationOutput = import("./pipelines/audio-classification.js").AudioClassificationOutput;
79
+ export type ZeroShotAudioClassificationOutput = import("./pipelines/zero-shot-audio-classification.js").ZeroShotAudioClassificationOutput;
80
+ export type AutomaticSpeechRecognitionOutput = import("./pipelines/automatic-speech-recognition.js").AutomaticSpeechRecognitionOutput;
81
+ export type TextToAudioOutput = import("./pipelines/text-to-audio.js").TextToAudioOutput;
82
+ export type ImageClassificationOutput = import("./pipelines/image-classification.js").ImageClassificationOutput;
83
+ export type ImageSegmentationOutput = import("./pipelines/image-segmentation.js").ImageSegmentationOutput;
84
+ export type ImageToTextOutput = import("./pipelines/image-to-text.js").ImageToTextOutput;
85
+ export type ObjectDetectionOutput = import("./pipelines/object-detection.js").ObjectDetectionOutput;
86
+ export type ZeroShotObjectDetectionOutput = import("./pipelines/zero-shot-object-detection.js").ZeroShotObjectDetectionOutput;
87
+ export type ZeroShotImageClassificationOutput = import("./pipelines/zero-shot-image-classification.js").ZeroShotImageClassificationOutput;
88
+ export type DocumentQuestionAnsweringOutput = import("./pipelines/document-question-answering.js").DocumentQuestionAnsweringOutput;
89
+ export type DepthEstimationOutput = import("./pipelines/depth-estimation.js").DepthEstimationOutput;
90
+ import { TextClassificationPipeline } from './pipelines/index.js';
91
+ import { TokenClassificationPipeline } from './pipelines/index.js';
92
+ import { QuestionAnsweringPipeline } from './pipelines/index.js';
93
+ import { FillMaskPipeline } from './pipelines/index.js';
94
+ import { SummarizationPipeline } from './pipelines/index.js';
95
+ import { TranslationPipeline } from './pipelines/index.js';
96
+ import { Text2TextGenerationPipeline } from './pipelines/index.js';
97
+ import { TextGenerationPipeline } from './pipelines/index.js';
98
+ import { ZeroShotClassificationPipeline } from './pipelines/index.js';
99
+ import { AudioClassificationPipeline } from './pipelines/index.js';
100
+ import { ZeroShotAudioClassificationPipeline } from './pipelines/index.js';
101
+ import { AutomaticSpeechRecognitionPipeline } from './pipelines/index.js';
102
+ import { TextToAudioPipeline } from './pipelines/index.js';
103
+ import { ImageToTextPipeline } from './pipelines/index.js';
104
+ import { ImageClassificationPipeline } from './pipelines/index.js';
105
+ import { ImageSegmentationPipeline } from './pipelines/index.js';
106
+ import { BackgroundRemovalPipeline } from './pipelines/index.js';
107
+ import { ZeroShotImageClassificationPipeline } from './pipelines/index.js';
108
+ import { ObjectDetectionPipeline } from './pipelines/index.js';
109
+ import { ZeroShotObjectDetectionPipeline } from './pipelines/index.js';
110
+ import { DocumentQuestionAnsweringPipeline } from './pipelines/index.js';
111
+ import { ImageToImagePipeline } from './pipelines/index.js';
112
+ import { DepthEstimationPipeline } from './pipelines/index.js';
113
+ import { FeatureExtractionPipeline } from './pipelines/index.js';
114
+ import { ImageFeatureExtractionPipeline } from './pipelines/index.js';
115
+ import { SUPPORTED_TASKS } from './pipelines/index.js';
116
+ import { TASK_ALIASES } from './pipelines/index.js';
357
117
  export { TextClassificationPipeline, TokenClassificationPipeline, QuestionAnsweringPipeline, FillMaskPipeline, SummarizationPipeline, TranslationPipeline, Text2TextGenerationPipeline, TextGenerationPipeline, ZeroShotClassificationPipeline, AudioClassificationPipeline, ZeroShotAudioClassificationPipeline, AutomaticSpeechRecognitionPipeline, TextToAudioPipeline, ImageToTextPipeline, ImageClassificationPipeline, ImageSegmentationPipeline, BackgroundRemovalPipeline, ZeroShotImageClassificationPipeline, ObjectDetectionPipeline, ZeroShotObjectDetectionPipeline, DocumentQuestionAnsweringPipeline, ImageToImagePipeline, DepthEstimationPipeline, FeatureExtractionPipeline, ImageFeatureExtractionPipeline };
358
118
  //# sourceMappingURL=pipelines.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipelines.d.ts","sourceRoot":"","sources":["../src/pipelines.js"],"names":[],"mappings":"AAoXA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,yBA7B4B,CAAC,SAAf,YAAa,QAChB,CAAC,UAuBD,MAAM,gKACN,OAAO,gBAAgB,EAAE,sBAAsB,GAC7C,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAyEhC;uBA9GY,MAAM,OAAO,eAAe;wBAC5B,MAAM,OAAO,YAAY;;;;2BACzB,QAAQ,GAAG,SAAS;;;;6BACpB,GAAE,CAAC,IAAI,QAAQ,GAAG,YAAY,CAAC,CAAA,OAAO,eAAe,EAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,GAAC;;;;yBACtE,GAAE,CAAC,IAAI,SAAS,GAAG,YAAY,CAAC,CAAA,OA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,qBAAqB;4CAC/D,OAAO,2CAA2C,EAAE,6BAA6B;gDACjF,OAAO,+CAA+C,EAAE,iCAAiC;8CACzF,OAAO,4CAA4C,EAAE,+BAA+B;oCACpF,OAAO,iCAAiC,EAAE,qBAAqB;2CA5OrE,sBAAsB;4CAAtB,sBAAsB;0CAAtB,sBAAsB;iCAAtB,sBAAsB;sCAAtB,sBAAsB;oCAAtB,sBAAsB;4CAAtB,sBAAsB;uCAAtB,sBAAsB;+CAAtB,sBAAsB;4CAAtB,sBAAsB;oDAAtB,sBAAsB;mDAAtB,sBAAsB;oCAAtB,sBAAsB;oCAAtB,sBAAsB;4CAAtB,sBAAsB;0CAAtB,sBAAsB;0CAAtB,sBAAsB;oDAAtB,sBAAsB;wCAAtB,sBAAsB;gDAAtB,sBAAsB;kDAAtB,sBAAsB;qCAAtB,sBAAsB;wCAAtB,sBAAsB;0CAAtB,sBAAsB;+CAAtB,sBAAsB;gCAAtB,sBAAsB;6BAAtB,sBAAsB"}
@@ -93,20 +93,20 @@ export class PreTrainedTokenizer extends PreTrainedTokenizer_base {
93
93
  * @param {string|string[]} [options.text_pair=null] Optional second sequence to be encoded. If set, must be the same type as text.
94
94
  * @param {boolean|'max_length'} [options.padding=false] Whether to pad the input sequences.
95
95
  * @param {boolean} [options.add_special_tokens=true] Whether or not to add the special tokens associated with the corresponding model.
96
- * @param {boolean} [options.truncation=null] Whether to truncate the input sequences.
97
- * @param {number} [options.max_length=null] Maximum length of the returned list and optionally padding length.
96
+ * @param {boolean|null} [options.truncation=null] Whether to truncate the input sequences.
97
+ * @param {number|null} [options.max_length=null] Maximum length of the returned list and optionally padding length.
98
98
  * @param {boolean} [options.return_tensor=true] Whether to return the results as Tensors or arrays.
99
- * @param {boolean} [options.return_token_type_ids=null] Whether to return the token type ids.
99
+ * @param {boolean|null} [options.return_token_type_ids=null] Whether to return the token type ids.
100
100
  * @returns {BatchEncoding} Object to be passed to the model.
101
101
  */
102
102
  _call(text: string | string[], { text_pair, add_special_tokens, padding, truncation, max_length, return_tensor, return_token_type_ids, }?: {
103
103
  text_pair?: string | string[];
104
104
  padding?: boolean | "max_length";
105
105
  add_special_tokens?: boolean;
106
- truncation?: boolean;
107
- max_length?: number;
106
+ truncation?: boolean | null;
107
+ max_length?: number | null;
108
108
  return_tensor?: boolean;
109
- return_token_type_ids?: boolean;
109
+ return_token_type_ids?: boolean | null;
110
110
  }): {
111
111
  /**
112
112
  * List of token ids to be fed to a model.
@@ -133,9 +133,9 @@ export class PreTrainedTokenizer extends PreTrainedTokenizer_base {
133
133
  *
134
134
  * @param {string} text The text to encode.
135
135
  * @param {Object} options An optional object containing the following properties:
136
- * @param {string} [options.text_pair=null] The optional second text to encode.
136
+ * @param {string|null} [options.text_pair=null] The optional second text to encode.
137
137
  * @param {boolean} [options.add_special_tokens=true] Whether or not to add the special tokens associated with the corresponding model.
138
- * @param {boolean} [options.return_token_type_ids=null] Whether to return token_type_ids.
138
+ * @param {boolean|null} [options.return_token_type_ids=null] Whether to return token_type_ids.
139
139
  * @returns {{input_ids: number[], attention_mask: number[], token_type_ids?: number[]}} An object containing the encoded text.
140
140
  * @private
141
141
  */
@@ -144,12 +144,12 @@ export class PreTrainedTokenizer extends PreTrainedTokenizer_base {
144
144
  * Converts a string into a sequence of tokens.
145
145
  * @param {string} text The sequence to be encoded.
146
146
  * @param {Object} options An optional object containing the following properties:
147
- * @param {string} [options.pair] A second sequence to be encoded with the first.
147
+ * @param {string|null} [options.pair] A second sequence to be encoded with the first.
148
148
  * @param {boolean} [options.add_special_tokens=false] Whether or not to add the special tokens associated with the corresponding model.
149
149
  * @returns {string[]} The list of tokens.
150
150
  */
151
151
  tokenize(text: string, { pair, add_special_tokens }?: {
152
- pair?: string;
152
+ pair?: string | null;
153
153
  add_special_tokens?: boolean;
154
154
  }): string[];
155
155
  /**
@@ -157,15 +157,15 @@ export class PreTrainedTokenizer extends PreTrainedTokenizer_base {
157
157
  *
158
158
  * @param {string} text The text to encode.
159
159
  * @param {Object} options An optional object containing the following properties:
160
- * @param {string} [options.text_pair=null] The optional second text to encode.
160
+ * @param {string|null} [options.text_pair=null] The optional second text to encode.
161
161
  * @param {boolean} [options.add_special_tokens=true] Whether or not to add the special tokens associated with the corresponding model.
162
- * @param {boolean} [options.return_token_type_ids=null] Whether to return token_type_ids.
162
+ * @param {boolean|null} [options.return_token_type_ids=null] Whether to return token_type_ids.
163
163
  * @returns {number[]} An array of token IDs representing the encoded text(s).
164
164
  */
165
165
  encode(text: string, { text_pair, add_special_tokens, return_token_type_ids }?: {
166
- text_pair?: string;
166
+ text_pair?: string | null;
167
167
  add_special_tokens?: boolean;
168
- return_token_type_ids?: boolean;
168
+ return_token_type_ids?: boolean | null;
169
169
  }): number[];
170
170
  /**
171
171
  * Decode a batch of tokenized sequences.
@@ -194,13 +194,13 @@ export class PreTrainedTokenizer extends PreTrainedTokenizer_base {
194
194
  * @param {number[]|bigint[]} token_ids List of token ids to decode
195
195
  * @param {Object} decode_args Optional arguments for decoding
196
196
  * @param {boolean} [decode_args.skip_special_tokens=false] Whether to skip special tokens during decoding
197
- * @param {boolean} [decode_args.clean_up_tokenization_spaces=null] Whether to clean up tokenization spaces during decoding.
197
+ * @param {boolean|null} [decode_args.clean_up_tokenization_spaces=null] Whether to clean up tokenization spaces during decoding.
198
198
  * If null, the value is set to `this.decoder.cleanup` if it exists, falling back to `this.clean_up_tokenization_spaces` if it exists, falling back to `true`.
199
199
  * @returns {string} The decoded string
200
200
  */
201
201
  decode_single(token_ids: number[] | bigint[], { skip_special_tokens, clean_up_tokenization_spaces }: {
202
202
  skip_special_tokens?: boolean;
203
- clean_up_tokenization_spaces?: boolean;
203
+ clean_up_tokenization_spaces?: boolean | null;
204
204
  }): string;
205
205
  /**
206
206
  * Retrieve the chat template string used for tokenizing chat messages. This template is used
@@ -208,7 +208,7 @@ export class PreTrainedTokenizer extends PreTrainedTokenizer_base {
208
208
  * template for better generation tracking.
209
209
  *
210
210
  * @param {Object} options An optional object containing the following properties:
211
- * @param {string} [options.chat_template=null]
211
+ * @param {string|null} [options.chat_template=null]
212
212
  * A Jinja template or the name of a template to use for this conversion.
213
213
  * It is usually not necessary to pass anything to this argument,
214
214
  * as the model's template will be used by default.
@@ -221,7 +221,7 @@ export class PreTrainedTokenizer extends PreTrainedTokenizer_base {
221
221
  * @returns {string} The chat template string.
222
222
  */
223
223
  get_chat_template({ chat_template, tools }?: {
224
- chat_template?: string;
224
+ chat_template?: string | null;
225
225
  tools?: any[];
226
226
  }): string;
227
227
  /**
@@ -254,7 +254,7 @@ export class PreTrainedTokenizer extends PreTrainedTokenizer_base {
254
254
  * @param {Message[]} conversation A list of message objects with `"role"` and `"content"` keys,
255
255
  * representing the chat history so far.
256
256
  * @param {Object} options An optional object containing the following properties:
257
- * @param {string} [options.chat_template=null] A Jinja template to use for this conversion. If
257
+ * @param {string|null} [options.chat_template=null] A Jinja template to use for this conversion. If
258
258
  * this is not passed, the model's chat template will be used instead.
259
259
  * @param {Object[]} [options.tools=null]
260
260
  * A list of tools (callable functions) that will be accessible to the model. If the template does not
@@ -275,7 +275,7 @@ export class PreTrainedTokenizer extends PreTrainedTokenizer_base {
275
275
  * @param {boolean} [options.tokenize=true] Whether to tokenize the output. If false, the output will be a string.
276
276
  * @param {boolean} [options.padding=false] Whether to pad sequences to the maximum length. Has no effect if tokenize is false.
277
277
  * @param {boolean} [options.truncation=false] Whether to truncate sequences to the maximum length. Has no effect if tokenize is false.
278
- * @param {number} [options.max_length=null] Maximum length (in tokens) to use for padding or truncation. Has no effect if tokenize is false.
278
+ * @param {number|null} [options.max_length=null] Maximum length (in tokens) to use for padding or truncation. Has no effect if tokenize is false.
279
279
  * If not specified, the tokenizer's `max_length` attribute will be used as a default.
280
280
  * @param {boolean} [options.return_tensor=true] Whether to return the output as a Tensor or an Array. Has no effect if tokenize is false.
281
281
  * @param {boolean} [options.return_dict=true] Whether to return a dictionary with named outputs. Has no effect if tokenize is false.
@@ -283,14 +283,14 @@ export class PreTrainedTokenizer extends PreTrainedTokenizer_base {
283
283
  * @returns {string | Tensor | number[]| number[][]|BatchEncoding} The tokenized output.
284
284
  */
285
285
  apply_chat_template(conversation: Message[], { tools, documents, chat_template, add_generation_prompt, tokenize, padding, truncation, max_length, return_tensor, return_dict, tokenizer_kwargs, ...kwargs }?: {
286
- chat_template?: string;
286
+ chat_template?: string | null;
287
287
  tools?: any[];
288
288
  documents?: Record<string, string>[];
289
289
  add_generation_prompt?: boolean;
290
290
  tokenize?: boolean;
291
291
  padding?: boolean;
292
292
  truncation?: boolean;
293
- max_length?: number;
293
+ max_length?: number | null;
294
294
  return_tensor?: boolean;
295
295
  return_dict?: boolean;
296
296
  tokenizer_kwargs?: any;
@@ -310,15 +310,33 @@ export class PreTrainedTokenizer extends PreTrainedTokenizer_base {
310
310
  };
311
311
  }
312
312
  export type PretrainedTokenizerOptions = import("./utils/hub.js").PretrainedOptions;
313
+ export type TextContent = {
314
+ type: "text";
315
+ text: string;
316
+ [key: string]: any;
317
+ };
318
+ export type ImageContent = {
319
+ type: "image";
320
+ image?: string | import("./utils/image.js").RawImage;
321
+ [key: string]: any;
322
+ };
323
+ /**
324
+ * Base type for message content. This is a discriminated union that can be extended with additional content types.
325
+ * Example: `@typedef {TextContent | ImageContent | AudioContent} MessageContent`
326
+ */
327
+ export type MessageContent = TextContent | ImageContent | {
328
+ type: string & {};
329
+ [key: string]: any;
330
+ };
313
331
  export type Message = {
314
332
  /**
315
- * The role of the message (e.g., "user" or "assistant" or "system").
333
+ * The role of the message.
316
334
  */
317
- role: string;
335
+ role: "user" | "assistant" | "system" | (string & {});
318
336
  /**
319
- * The content of the message.
337
+ * The content of the message. Can be a simple string or an array of content objects.
320
338
  */
321
- content: string;
339
+ content: string | MessageContent[];
322
340
  };
323
341
  import { Tensor } from './utils/tensor.js';
324
342
  import { Tokenizer } from '@huggingface/tokenizers';
@@ -1 +1 @@
1
- {"version":3,"file":"tokenization_utils.d.ts","sourceRoot":"","sources":["../src/tokenization_utils.js"],"names":[],"mapp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,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC;;;;aAC/C,MAAM,GAAG,cAAc,EAAE;;uBA7EhB,mBAAmB;0BAPhB,yBAAyB"}
@@ -1,4 +1,3 @@
1
- export { env } from "./env.js";
2
1
  export * from "./pipelines.js";
3
2
  export * from "./models/models.js";
4
3
  export * from "./models/auto/modeling_auto.js";
@@ -14,11 +13,18 @@ export * from "./generation/streamers.js";
14
13
  export * from "./generation/stopping_criteria.js";
15
14
  export * from "./generation/logits_process.js";
16
15
  export * from "./utils/tensor.js";
16
+ export { random } from "./utils/random.js";
17
+ export { DynamicCache } from "./cache_utils.js";
18
+ export { ModelRegistry } from "./utils/model_registry/ModelRegistry.js";
17
19
  export type PretrainedModelOptions = import("./utils/hub.js").PretrainedModelOptions;
18
20
  export type PretrainedProcessorOptions = import("./processing_utils.js").PretrainedProcessorOptions;
21
+ export type Message = import("./tokenization_utils.js").Message;
19
22
  export type PretrainedTokenizerOptions = import("./tokenization_utils.js").PretrainedTokenizerOptions;
20
23
  export type DataType = import("./utils/dtypes.js").DataType;
21
24
  export type DeviceType = import("./utils/devices.js").DeviceType;
25
+ export type ProgressCallback = import("./utils/core.js").ProgressCallback;
26
+ export type ProgressInfo = import("./utils/core.js").ProgressInfo;
27
+ export { env, LogLevel } from "./env.js";
22
28
  export { PretrainedConfig, AutoConfig } from "./configs.js";
23
29
  export { read_audio, RawAudio } from "./utils/audio.js";
24
30
  export { load_image, RawImage } from "./utils/image.js";
@@ -1 +1 @@
1
- {"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../src/transformers.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;qCAwDa,OAAO,gBAAgB,EAAE,sBAAsB;yCAC/C,OAAO,uBAAuB,EAAE,0BAA0B;yCAC1D,OAAO,yBAAyB,EAAE,0BAA0B;uBAC5D,OAAO,mBAAmB,EAAE,QAAQ;yBACpC,OAAO,oBAAoB,EAAE,UAAU"}
1
+ {"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../src/transformers.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;qCA8Da,OAAO,gBAAgB,EAAE,sBAAsB;yCAC/C,OAAO,uBAAuB,EAAE,0BAA0B;sBAC1D,OAAO,yBAAyB,EAAE,OAAO;yCACzC,OAAO,yBAAyB,EAAE,0BAA0B;uBAC5D,OAAO,mBAAmB,EAAE,QAAQ;yBACpC,OAAO,oBAAoB,EAAE,UAAU;+BACvC,OAAO,iBAAiB,EAAE,gBAAgB;2BAC1C,OAAO,iBAAiB,EAAE,YAAY"}
@@ -76,8 +76,10 @@ export function mel_filter_bank(num_frequency_bins: number, num_mel_filters: num
76
76
  * If supplied, applies this filter bank to create a mel spectrogram.
77
77
  * @param {number} [options.mel_floor=1e-10] Minimum value of mel frequency banks.
78
78
  * @param {string} [options.log_mel=null] How to convert the spectrogram to log scale. Possible options are:
79
- * `null` (don't convert), `"log"` (take the natural logarithm) `"log10"` (take the base-10 logarithm), `"dB"` (convert to decibels).
79
+ * `null` (don't convert), `"log"` (take the natural logarithm), `"log10"` (take the base-10 logarithm), `"dB"` (convert to decibels),
80
+ * `"log10_max_norm"` (take `log10`, then apply `(max(x, maxVal - 8) + 4) / 4` normalization, where `maxVal` is computed from data or given by `max_log_mel`).
80
81
  * Can only be used when `power` is not `null`.
82
+ * @param {number} [options.max_log_mel=null] When `log_mel` is `"log10_max_norm"`, use this fixed value as the max instead of computing from data.
81
83
  * @param {number} [options.reference=1.0] Sets the input spectrogram value that corresponds to 0 dB. For example, use `max(spectrogram)[0]` to set
82
84
  * the loudest part to 0 dB. Must be greater than zero.
83
85
  * @param {number} [options.min_value=1e-10] The spectrogram will be clipped to this minimum value before conversion to decibels, to avoid taking `log(0)`.
@@ -94,7 +96,7 @@ export function mel_filter_bank(num_frequency_bins: number, num_mel_filters: num
94
96
  * @param {number} [options.mel_offset=0] Offset to add to the mel spectrogram to avoid taking the log of zero.
95
97
  * @returns {Promise<Tensor>} Spectrogram of shape `(num_frequency_bins, length)` (regular spectrogram) or shape `(num_mel_filters, length)` (mel spectrogram).
96
98
  */
97
- export function spectrogram(waveform: Float32Array | Float64Array, window: Float32Array | Float64Array, frame_length: number, hop_length: number, { fft_length, power, center, pad_mode, onesided, preemphasis, preemphasis_htk_flavor, mel_filters, mel_floor, log_mel, reference, min_value, db_range, remove_dc_offset, min_num_frames, max_num_frames, do_pad, transpose, mel_offset, }?: {
99
+ export function spectrogram(waveform: Float32Array | Float64Array, window: Float32Array | Float64Array, frame_length: number, hop_length: number, { fft_length, power, center, pad_mode, onesided, preemphasis, preemphasis_htk_flavor, mel_filters, mel_floor, log_mel, max_log_mel, reference, min_value, db_range, remove_dc_offset, min_num_frames, max_num_frames, do_pad, transpose, mel_offset, }?: {
98
100
  fft_length?: number;
99
101
  power?: number;
100
102
  center?: boolean;
@@ -105,6 +107,7 @@ export function spectrogram(waveform: Float32Array | Float64Array, window: Float
105
107
  mel_filters?: number[][];
106
108
  mel_floor?: number;
107
109
  log_mel?: string;
110
+ max_log_mel?: number;
108
111
  reference?: number;
109
112
  min_value?: number;
110
113
  db_range?: number;