@genai-fi/nanogpt 1.6.0 → 1.7.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 (426) hide show
  1. package/dist/{binary_op_util-WY9YIl0q.js → Reshape-CqftURg0.js} +75 -60
  2. package/dist/TeachableLLM.d.ts +12 -12
  3. package/dist/api/beamer.d.ts +4 -4
  4. package/dist/api/responses.d.ts +4 -4
  5. package/dist/api/training.d.ts +9 -9
  6. package/dist/backend.d.ts +1 -1
  7. package/dist/backend_util-DZIc6pyV.js +1081 -0
  8. package/dist/checks/index.d.ts +11 -11
  9. package/dist/checks/weights.d.ts +1 -1
  10. package/dist/data/docx.d.ts +1 -1
  11. package/dist/data/pdf.d.ts +1 -1
  12. package/dist/data/stream.d.ts +1 -1
  13. package/dist/data/textLoader.d.ts +1 -1
  14. package/dist/data.d.ts +3 -3
  15. package/dist/device-CZPGtQBU.js +9 -0
  16. package/dist/device.d.ts +2 -0
  17. package/dist/{dist-DeVH1nGn.js → dist-DiszGjH-.js} +1833 -1844
  18. package/dist/{dist-CMMLi-qO.js → dist-JOPw9zTN.js} +69 -11
  19. package/dist/inference/Beamer.d.ts +3 -3
  20. package/dist/inference/Generator.d.ts +4 -4
  21. package/dist/inference/tokenisePrompt.d.ts +2 -2
  22. package/dist/inference/types.d.ts +1 -1
  23. package/dist/inference/utilities.d.ts +1 -1
  24. package/dist/layers/BaseLayer.d.ts +5 -4
  25. package/dist/layers/GQA.d.ts +24 -26
  26. package/dist/layers/HeadLayer.d.ts +2 -2
  27. package/dist/layers/LoRA.d.ts +1 -1
  28. package/dist/layers/MHA.d.ts +3 -4
  29. package/dist/layers/MLP.d.ts +2 -2
  30. package/dist/layers/PositionEmbedding.d.ts +3 -3
  31. package/dist/layers/RMSNorm.d.ts +2 -2
  32. package/dist/layers/RoPECache.d.ts +2 -1
  33. package/dist/layers/TiedEmbedding.d.ts +2 -2
  34. package/dist/layers/TransformerBlock.d.ts +9 -6
  35. package/dist/layers.d.ts +4 -4
  36. package/dist/loader/load.d.ts +1 -1
  37. package/dist/loader/loadHF.d.ts +3 -3
  38. package/dist/loader/loadTransformers.d.ts +2 -2
  39. package/dist/loader/loadZipMeta.d.ts +2 -2
  40. package/dist/loader/newZipLoad.d.ts +2 -2
  41. package/dist/loader/oldZipLoad.d.ts +4 -4
  42. package/dist/loader/save.d.ts +5 -5
  43. package/dist/loader/types.d.ts +23 -10
  44. package/dist/main.d.ts +40 -24
  45. package/dist/matMul16-CiMKJM8v.js +2610 -0
  46. package/dist/models/Llama.d.ts +2 -2
  47. package/dist/models/LoopNano.d.ts +16 -0
  48. package/dist/models/NanoGPTV1.d.ts +2 -2
  49. package/dist/models/NanoGPTV2.d.ts +2 -2
  50. package/dist/models/Qwen3.d.ts +2 -2
  51. package/dist/models/config.d.ts +11 -1
  52. package/dist/models/factory.d.ts +2 -2
  53. package/dist/models/model.d.ts +6 -6
  54. package/dist/models.d.ts +4 -4
  55. package/dist/nanogpt.js +37041 -0
  56. package/dist/ops/adamAdjust.d.ts +2 -0
  57. package/dist/ops/adamMoments.d.ts +2 -0
  58. package/dist/ops/adamW.d.ts +2 -0
  59. package/dist/ops/add16.d.ts +1 -0
  60. package/dist/ops/appendCache.d.ts +2 -0
  61. package/dist/ops/attentionMask.d.ts +11 -1
  62. package/dist/ops/dropout16.d.ts +2 -0
  63. package/dist/ops/gatherSub.d.ts +2 -0
  64. package/dist/ops/gelu.d.ts +3 -0
  65. package/dist/ops/log.d.ts +1 -0
  66. package/dist/ops/matMul16.d.ts +4 -0
  67. package/dist/ops/matMulGelu.d.ts +3 -0
  68. package/dist/ops/matMulMul.d.ts +2 -0
  69. package/dist/ops/mul16.d.ts +1 -0
  70. package/dist/ops/mulDrop.d.ts +2 -0
  71. package/dist/ops/normRMS.d.ts +3 -0
  72. package/dist/ops/pack16.d.ts +1 -0
  73. package/dist/ops/qkv.d.ts +13 -1
  74. package/dist/ops/rope.d.ts +4 -1
  75. package/dist/ops/scatterSub.d.ts +4 -1
  76. package/dist/ops/silu.d.ts +1 -0
  77. package/dist/ops/softmax16.d.ts +1 -0
  78. package/dist/ops/sparseCrossEntropy.d.ts +15 -0
  79. package/dist/ops/unpack16.d.ts +1 -0
  80. package/dist/ops/webgl/sparseCrossEntropy.d.ts +1 -0
  81. package/dist/ops/webgpu/adamW.d.ts +1 -0
  82. package/dist/ops/webgpu/concat16.d.ts +16 -0
  83. package/dist/ops/webgpu/index.d.ts +29 -0
  84. package/dist/ops/webgpu/normRMS16_program.d.ts +2 -2
  85. package/dist/ops/webgpu/normRMS32_program.d.ts +2 -2
  86. package/dist/ops/webgpu/pack16_program.d.ts +1 -1
  87. package/dist/ops/webgpu/softmax16_program.d.ts +16 -0
  88. package/dist/ops/webgpu/sparseCrossEntropy.d.ts +1 -0
  89. package/dist/ops/webgpu/utils/binary_op.d.ts +16 -0
  90. package/dist/ops/webgpu/utils/deviceInfo.d.ts +1 -1
  91. package/dist/ops/webgpu/utils/reductions.d.ts +1 -1
  92. package/dist/patches/webgpu_backend.d.ts +2 -1
  93. package/dist/patches/webgpu_base.d.ts +0 -1
  94. package/dist/patches/webgpu_program.d.ts +21 -0
  95. package/dist/{shared-BIDMUBCs.js → shared-BARkvvG4.js} +587 -505
  96. package/dist/tokenise.d.ts +4 -4
  97. package/dist/tokeniser/BaseTokeniser.d.ts +3 -3
  98. package/dist/tokeniser/CharTokeniser.d.ts +2 -2
  99. package/dist/tokeniser/bpe.d.ts +2 -2
  100. package/dist/tokeniser/type.d.ts +2 -2
  101. package/dist/training/AdamW.d.ts +19 -2
  102. package/dist/training/BasicTrainer.d.ts +5 -5
  103. package/dist/training/DatasetBuilder.d.ts +2 -2
  104. package/dist/training/Evaluator.d.ts +1 -1
  105. package/dist/training/LRScheduler.d.ts +1 -1
  106. package/dist/training/PreTrainer.d.ts +6 -6
  107. package/dist/training/SFTTrainer.d.ts +6 -6
  108. package/dist/training/configure.d.ts +2 -2
  109. package/dist/training/factory.d.ts +6 -5
  110. package/dist/training/prepareData.d.ts +6 -6
  111. package/dist/training/tasks/tokenStream.d.ts +3 -3
  112. package/dist/training/types.d.ts +6 -5
  113. package/dist/training/validateOptions.d.ts +1 -1
  114. package/dist/training/validation.d.ts +3 -3
  115. package/dist/utilities/datasetID.d.ts +1 -1
  116. package/dist/utilities/dummy.d.ts +1 -1
  117. package/dist/utilities/packed.d.ts +1 -1
  118. package/dist/utilities/parameters.d.ts +1 -1
  119. package/dist/utilities/sentences.d.ts +1 -1
  120. package/dist/utilities/waitForModel.d.ts +1 -1
  121. package/dist/webgpu-D4syGmzo.js +3221 -0
  122. package/dist/webgpu-wUCQopBN.js +1007 -0
  123. package/dist/{webgpu_program-DvkFqRlR.js → webgpu_backend-CzY9TzvA.js} +174 -223
  124. package/dist/{patches/webgpu_base.js → webgpu_base-Bjg7okYf.js} +6 -9
  125. package/package.json +12 -9
  126. package/dist/DatasetBuilder-DRDW8tcM.js +0 -731
  127. package/dist/Generator-BcR_14Cj.js +0 -316
  128. package/dist/RealDiv-Cl8k3YTx.js +0 -354
  129. package/dist/Reshape-CKxKPKqi.js +0 -91
  130. package/dist/Reshape-H5zZRgr9.js +0 -16
  131. package/dist/RoPECache-dYscFINl.js +0 -722
  132. package/dist/TeachableLLM.js +0 -220
  133. package/dist/api/beamer.js +0 -61
  134. package/dist/api/responses.js +0 -177
  135. package/dist/api/training.js +0 -215
  136. package/dist/axis_util-rF9RnwKE.js +0 -37
  137. package/dist/backend.js +0 -12
  138. package/dist/backend_util-Cpp0Gwlp.js +0 -394
  139. package/dist/broadcast_to-CGvLNiQ0.js +0 -20
  140. package/dist/checks/appendCache.js +0 -55
  141. package/dist/checks/attentionMask.js +0 -57
  142. package/dist/checks/check.js +0 -31
  143. package/dist/checks/gelu.js +0 -46
  144. package/dist/checks/index.js +0 -27
  145. package/dist/checks/matMulGelu.js +0 -84
  146. package/dist/checks/normRMS.js +0 -30
  147. package/dist/checks/normRMSGrad.js +0 -23
  148. package/dist/checks/packUnpack.js +0 -46
  149. package/dist/checks/qkv.js +0 -1
  150. package/dist/checks/rope.js +0 -30
  151. package/dist/checks/weights.js +0 -26
  152. package/dist/clip_by_value-D-UX9am5.js +0 -13
  153. package/dist/complex-Cl904TqN.js +0 -13
  154. package/dist/complex_util-BBlPAm-s.js +0 -59
  155. package/dist/concat-Oip5acVY.js +0 -14
  156. package/dist/concat_util-CY45Hf4F.js +0 -18
  157. package/dist/data/docx.js +0 -17
  158. package/dist/data/pdf.js +0 -14
  159. package/dist/data/stream.js +0 -1
  160. package/dist/data/textLoader.js +0 -575
  161. package/dist/data-CV_i_H6B.js +0 -11
  162. package/dist/data.js +0 -5
  163. package/dist/dist-DyL7qSLJ.js +0 -7809
  164. package/dist/dropout16-CA31Ud5a.js +0 -20
  165. package/dist/dropout_util-SiFMbFXz.js +0 -22
  166. package/dist/eventemitter3-wmfmOP_f.js +0 -90
  167. package/dist/expand_dims-Dh3Fulyn.js +0 -10
  168. package/dist/floor-BwjmUb7X.js +0 -8
  169. package/dist/gather-B5Z1RFt5.js +0 -14
  170. package/dist/gatherSub-CRUfUzBa.js +0 -22
  171. package/dist/gelu-Xx9-ohH9.js +0 -25
  172. package/dist/gpgpu_math-48m8q3jI.js +0 -1591
  173. package/dist/inference/Beamer.js +0 -215
  174. package/dist/inference/Generator.js +0 -1
  175. package/dist/inference/tokenisePrompt.js +0 -17
  176. package/dist/inference/types.js +0 -0
  177. package/dist/inference/utilities.js +0 -31
  178. package/dist/jszip.min-Btv48m44.js +0 -3037
  179. package/dist/kernel_funcs_utils-BYRpSfV_.js +0 -229
  180. package/dist/layers/BaseLayer.js +0 -75
  181. package/dist/layers/GQA.js +0 -102
  182. package/dist/layers/HeadLayer.js +0 -28
  183. package/dist/layers/LoRA.js +0 -45
  184. package/dist/layers/MHA.js +0 -102
  185. package/dist/layers/MLP.js +0 -47
  186. package/dist/layers/PositionEmbedding.js +0 -28
  187. package/dist/layers/RMSNorm.js +0 -25
  188. package/dist/layers/RoPECache.js +0 -1
  189. package/dist/layers/TiedEmbedding.js +0 -33
  190. package/dist/layers/TransformerBlock.js +0 -50
  191. package/dist/layers/WeightStore.js +0 -68
  192. package/dist/layers-CFqEip3s.js +0 -13
  193. package/dist/layers.js +0 -6
  194. package/dist/loader/load.js +0 -63
  195. package/dist/loader/loadHF.js +0 -17
  196. package/dist/loader/loadTransformers.js +0 -61
  197. package/dist/loader/loadZipMeta.js +0 -15
  198. package/dist/loader/newZipLoad.js +0 -24
  199. package/dist/loader/oldZipLoad.js +0 -36
  200. package/dist/loader/save.js +0 -89
  201. package/dist/loader/types.js +0 -0
  202. package/dist/main.js +0 -12145
  203. package/dist/matMul16-tE26fnhf.js +0 -87
  204. package/dist/matMulGelu-ASUWlKqu.js +0 -162
  205. package/dist/mat_mul-R9_DWmIT.js +0 -16
  206. package/dist/models/Llama.js +0 -88
  207. package/dist/models/NanoGPTV1.js +0 -94
  208. package/dist/models/NanoGPTV2.js +0 -85
  209. package/dist/models/Qwen3.js +0 -88
  210. package/dist/models/config.js +0 -32
  211. package/dist/models/factory.js +0 -16
  212. package/dist/models/model.js +0 -75
  213. package/dist/models-DyBpJJwM.js +0 -13
  214. package/dist/models.js +0 -6
  215. package/dist/mul16-C7sqgqik.js +0 -41
  216. package/dist/non_max_suppression_impl-B0H318rb.js +0 -72
  217. package/dist/not_equal-Bu3O8rh_.js +0 -67
  218. package/dist/one_hot-TEMPumJj.js +0 -14
  219. package/dist/ones-DpPXWa6A.js +0 -13
  220. package/dist/ops/adamAdjust.js +0 -17
  221. package/dist/ops/adamMoments.js +0 -15
  222. package/dist/ops/add16.js +0 -11
  223. package/dist/ops/appendCache.js +0 -26
  224. package/dist/ops/attentionMask.js +0 -19
  225. package/dist/ops/concat16.js +0 -8
  226. package/dist/ops/cpu/adamAdjust.js +0 -15
  227. package/dist/ops/cpu/adamMoments.js +0 -16
  228. package/dist/ops/cpu/appendCache.js +0 -65
  229. package/dist/ops/cpu/attentionMask.js +0 -20
  230. package/dist/ops/cpu/fusedSoftmax.js +0 -22
  231. package/dist/ops/cpu/gatherSub.js +0 -1
  232. package/dist/ops/cpu/gelu.js +0 -35
  233. package/dist/ops/cpu/matMul16.js +0 -14
  234. package/dist/ops/cpu/matMulGelu.js +0 -44
  235. package/dist/ops/cpu/matMulMul.js +0 -19
  236. package/dist/ops/cpu/mulDropout.js +0 -19
  237. package/dist/ops/cpu/normRMS.js +0 -34
  238. package/dist/ops/cpu/qkv.js +0 -74
  239. package/dist/ops/cpu/rope.js +0 -84
  240. package/dist/ops/cpu/scatterSub.js +0 -1
  241. package/dist/ops/dot16.js +0 -28
  242. package/dist/ops/dropout.js +0 -12
  243. package/dist/ops/dropout16.js +0 -1
  244. package/dist/ops/gatherSub.js +0 -12
  245. package/dist/ops/gelu.js +0 -1
  246. package/dist/ops/globalNorm.js +0 -19
  247. package/dist/ops/grads/add16.js +0 -26
  248. package/dist/ops/grads/attentionMask.js +0 -25
  249. package/dist/ops/grads/dropout16.js +0 -1
  250. package/dist/ops/grads/gelu.js +0 -1
  251. package/dist/ops/grads/matMul16.js +0 -1
  252. package/dist/ops/grads/matMulGelu.js +0 -21
  253. package/dist/ops/grads/mul16.js +0 -1
  254. package/dist/ops/grads/normRMS.js +0 -36
  255. package/dist/ops/grads/pack16.js +0 -1
  256. package/dist/ops/grads/qkv.js +0 -46
  257. package/dist/ops/grads/rope.js +0 -1
  258. package/dist/ops/grads/silu.js +0 -1
  259. package/dist/ops/grads/softmax16.js +0 -22
  260. package/dist/ops/grads/unpack16.js +0 -1
  261. package/dist/ops/grads/utils.js +0 -11
  262. package/dist/ops/log.js +0 -1
  263. package/dist/ops/matMul16.js +0 -1
  264. package/dist/ops/matMulGelu.js +0 -19
  265. package/dist/ops/matMulMul.js +0 -15
  266. package/dist/ops/mul16.js +0 -1
  267. package/dist/ops/mulDrop.js +0 -14
  268. package/dist/ops/normRMS.js +0 -21
  269. package/dist/ops/pack16.js +0 -1
  270. package/dist/ops/qkv.js +0 -15
  271. package/dist/ops/reshape16.js +0 -33
  272. package/dist/ops/rope.js +0 -1
  273. package/dist/ops/scatterSub.js +0 -12
  274. package/dist/ops/silu.js +0 -1
  275. package/dist/ops/slice16.js +0 -11
  276. package/dist/ops/softmax16.js +0 -8
  277. package/dist/ops/sub16.js +0 -10
  278. package/dist/ops/sum16.js +0 -13
  279. package/dist/ops/transpose16.js +0 -33
  280. package/dist/ops/unpack16.js +0 -1
  281. package/dist/ops/webgl/adamAdjust.js +0 -81
  282. package/dist/ops/webgl/adamMoments.js +0 -43
  283. package/dist/ops/webgl/appendCache.js +0 -52
  284. package/dist/ops/webgl/attentionMask.js +0 -63
  285. package/dist/ops/webgl/dropout16.js +0 -11
  286. package/dist/ops/webgl/fusedSoftmax.js +0 -70
  287. package/dist/ops/webgl/gatherSub.js +0 -27
  288. package/dist/ops/webgl/gelu.js +0 -47
  289. package/dist/ops/webgl/log.js +0 -14
  290. package/dist/ops/webgl/matMul16.js +0 -48
  291. package/dist/ops/webgl/matMulGelu.js +0 -1
  292. package/dist/ops/webgl/matMulMul.js +0 -23
  293. package/dist/ops/webgl/mulDropout.js +0 -31
  294. package/dist/ops/webgl/normRMS.js +0 -115
  295. package/dist/ops/webgl/qkv.js +0 -53
  296. package/dist/ops/webgl/rope.js +0 -73
  297. package/dist/ops/webgl/scatterSub.js +0 -27
  298. package/dist/ops/webgpu/adamAdjust.js +0 -76
  299. package/dist/ops/webgpu/adamMoments.js +0 -75
  300. package/dist/ops/webgpu/add16.js +0 -13
  301. package/dist/ops/webgpu/appendCache.js +0 -129
  302. package/dist/ops/webgpu/attentionMask.js +0 -41
  303. package/dist/ops/webgpu/attentionMask32_program.js +0 -61
  304. package/dist/ops/webgpu/clipScale.js +0 -44
  305. package/dist/ops/webgpu/concat16.js +0 -110
  306. package/dist/ops/webgpu/dropout16.js +0 -58
  307. package/dist/ops/webgpu/gatherSub.js +0 -51
  308. package/dist/ops/webgpu/gelu.js +0 -146
  309. package/dist/ops/webgpu/index.js +0 -27
  310. package/dist/ops/webgpu/matMul16.js +0 -91
  311. package/dist/ops/webgpu/matMul16_program.js +0 -311
  312. package/dist/ops/webgpu/mul16.js +0 -13
  313. package/dist/ops/webgpu/norm2.js +0 -45
  314. package/dist/ops/webgpu/normRMS.js +0 -25
  315. package/dist/ops/webgpu/normRMS16_program.js +0 -28
  316. package/dist/ops/webgpu/normRMS32_program.js +0 -28
  317. package/dist/ops/webgpu/normRMSGrad.js +0 -225
  318. package/dist/ops/webgpu/pack16.js +0 -20
  319. package/dist/ops/webgpu/pack16_program.js +0 -92
  320. package/dist/ops/webgpu/qkv.js +0 -63
  321. package/dist/ops/webgpu/rope.js +0 -227
  322. package/dist/ops/webgpu/scatterSub.js +0 -52
  323. package/dist/ops/webgpu/silu.js +0 -117
  324. package/dist/ops/webgpu/slice16.js +0 -73
  325. package/dist/ops/webgpu/softmax16.js +0 -18
  326. package/dist/ops/webgpu/softmax16_program.js +0 -88
  327. package/dist/ops/webgpu/softmax16_subgroup_program.js +0 -69
  328. package/dist/ops/webgpu/softmax16grad.js +0 -30
  329. package/dist/ops/webgpu/sub16.js +0 -13
  330. package/dist/ops/webgpu/sum16.js +0 -30
  331. package/dist/ops/webgpu/transpose16.js +0 -38
  332. package/dist/ops/webgpu/transpose16_program.js +0 -50
  333. package/dist/ops/webgpu/transpose16_shared_program.js +0 -78
  334. package/dist/ops/webgpu/unpack16.js +0 -59
  335. package/dist/ops/webgpu/utils/binary_op.js +0 -140
  336. package/dist/ops/webgpu/utils/deviceInfo.js +0 -10
  337. package/dist/ops/webgpu/utils/reductions.js +0 -264
  338. package/dist/ops-Be5ACU5R.js +0 -13
  339. package/dist/ops-C1UpdEYM.js +0 -509
  340. package/dist/pack16-BHO4t1-M.js +0 -36
  341. package/dist/pad-Dy-1IP3A.js +0 -13
  342. package/dist/patches/webgpu_backend.js +0 -42
  343. package/dist/patches/webgpu_program.js +0 -292
  344. package/dist/picomatch--TW6gyBJ.js +0 -999
  345. package/dist/qkv-BQfNPucX.js +0 -42
  346. package/dist/rand_util-_vCY93Uw.js +0 -44
  347. package/dist/random_normal-DUIT8kyC.js +0 -11
  348. package/dist/range-CYvQC3fW.js +0 -13
  349. package/dist/relu-C4XULT8A.js +0 -8
  350. package/dist/reshape-DJb1jgMt.js +0 -8
  351. package/dist/resize_nearest_neighbor-DAqcTYUe.js +0 -188
  352. package/dist/rope-JjBVufF_.js +0 -24
  353. package/dist/scatterSub-BOnqk-uY.js +0 -27
  354. package/dist/scatter_nd_util-BepMCpLY.js +0 -34
  355. package/dist/seedrandom-SHEGFK6H.js +0 -282
  356. package/dist/selu_util-DeOTf-sc.js +0 -27
  357. package/dist/shared-CX_iPI5K.js +0 -4
  358. package/dist/silu-DsAE2cJ5.js +0 -23
  359. package/dist/slice-Dlb1FlzG.js +0 -13
  360. package/dist/slice_util-BVgPRoij.js +0 -207
  361. package/dist/softmax-Dpav_dWw.js +0 -10
  362. package/dist/split-DYnT8chz.js +0 -11
  363. package/dist/squeeze-B3XYGAlg.js +0 -9
  364. package/dist/stack-Dbbt9mIk.js +0 -10
  365. package/dist/step-DA-5DNu9.js +0 -348
  366. package/dist/stream-BBe2apn4.js +0 -2280
  367. package/dist/sum-C8qNbFNp.js +0 -13
  368. package/dist/tensor-ALxWZfmz.js +0 -7
  369. package/dist/tensor1d-BHgkkhTE.js +0 -9
  370. package/dist/tensor2d-ARItvqVn.js +0 -10
  371. package/dist/tensor4d-D1zRBipJ.js +0 -10
  372. package/dist/tfjs_backend-CsXOum0h.js +0 -685
  373. package/dist/tile-DfyQ0KX-.js +0 -10
  374. package/dist/tokenise-DbS2Ea-T.js +0 -14
  375. package/dist/tokenise.js +0 -6
  376. package/dist/tokeniser/BaseTokeniser.js +0 -137
  377. package/dist/tokeniser/CharTokeniser.js +0 -85
  378. package/dist/tokeniser/bpe.js +0 -156
  379. package/dist/tokeniser/messages.js +0 -0
  380. package/dist/tokeniser/type.js +0 -0
  381. package/dist/topk-BrU2pkrR.js +0 -19
  382. package/dist/training/AdamW.js +0 -132
  383. package/dist/training/BasicTrainer.js +0 -274
  384. package/dist/training/DatasetBuilder.js +0 -1
  385. package/dist/training/Evaluator.js +0 -51
  386. package/dist/training/LRScheduler.js +0 -37
  387. package/dist/training/PreTrainer.js +0 -21
  388. package/dist/training/SFTTrainer.js +0 -23
  389. package/dist/training/configure.js +0 -33
  390. package/dist/training/factory.js +0 -7
  391. package/dist/training/loss.js +0 -18
  392. package/dist/training/orthoGrad.js +0 -9
  393. package/dist/training/prepareData.js +0 -51
  394. package/dist/training/sparseCrossEntropy.js +0 -53
  395. package/dist/training/tasks/TokenStore.js +0 -217
  396. package/dist/training/tasks/tokenStream.js +0 -45
  397. package/dist/training/types.js +0 -0
  398. package/dist/training/validateOptions.js +0 -18
  399. package/dist/training/validation.js +0 -30
  400. package/dist/transpose-BC-M_OoT.js +0 -34
  401. package/dist/unsorted_segment_sum-BelC7R-q.js +0 -408
  402. package/dist/utilities/arrayClose.js +0 -29
  403. package/dist/utilities/arrayShape.js +0 -7
  404. package/dist/utilities/datasetID.js +0 -17
  405. package/dist/utilities/dummy.js +0 -36
  406. package/dist/utilities/float16.js +0 -46
  407. package/dist/utilities/maxHeap.js +0 -54
  408. package/dist/utilities/multinomialCPU.js +0 -7
  409. package/dist/utilities/naming.js +0 -0
  410. package/dist/utilities/packed.js +0 -12
  411. package/dist/utilities/parameters.js +0 -53
  412. package/dist/utilities/performance.js +0 -15
  413. package/dist/utilities/profile.js +0 -32
  414. package/dist/utilities/random.js +0 -18
  415. package/dist/utilities/safetensors.js +0 -63
  416. package/dist/utilities/sentences.js +0 -35
  417. package/dist/utilities/tokenParse.js +0 -16
  418. package/dist/utilities/tokens.js +0 -39
  419. package/dist/utilities/topP.js +0 -25
  420. package/dist/utilities/waitForModel.js +0 -11
  421. package/dist/utilities/weights.js +0 -40
  422. package/dist/utilities/yielder.js +0 -6
  423. package/dist/v4-YCkfo8OR.js +0 -27
  424. package/dist/webgpu-BHX-uBym.js +0 -518
  425. package/dist/webgpu_util-5QTyovaf.js +0 -105
  426. package/dist/zeros-hxKGkRfl.js +0 -12
@@ -1,575 +0,0 @@
1
- import { i as e, t } from "../rolldown-runtime-CwxnZyOB.js";
2
- import { loadPDF as n } from "./pdf.js";
3
- import { loadDOCX as r } from "./docx.js";
4
- import { n as i, r as a, t as o } from "../stream-BBe2apn4.js";
5
- // lib/data/textLoader.ts
6
- var s = /* @__PURE__ */ e((/* @__PURE__ */ t(((e, t, n) => {
7
- ((n, r) => {
8
- typeof define == "function" && define.amd ? define([], r) : typeof t == "object" && e !== void 0 ? t.exports = r() : n.Papa = r();
9
- })(n, function e() {
10
- var t = typeof self < "u" ? self : typeof window < "u" ? window : t === void 0 ? {} : t, n, r = !t.document && !!t.postMessage, i = t.IS_PAPA_WORKER || !1, a = {}, o = 0, s = {};
11
- function c(e) {
12
- this._handle = null, this._finished = !1, this._completed = !1, this._halted = !1, this._input = null, this._baseIndex = 0, this._partialLine = "", this._rowCount = 0, this._start = 0, this._nextChunk = null, this.isFirstChunk = !0, this._completeResults = {
13
- data: [],
14
- errors: [],
15
- meta: {}
16
- }, function(e) {
17
- var t = y(e);
18
- t.chunkSize = parseInt(t.chunkSize), e.step || e.chunk || (t.chunkSize = null), this._handle = new p(t), (this._handle.streamer = this)._config = t;
19
- }.call(this, e), this.parseChunk = function(e, n) {
20
- var r = parseInt(this._config.skipFirstNLines) || 0;
21
- if (this.isFirstChunk && 0 < r) {
22
- let t = this._config.newline;
23
- t ||= (a = this._config.quoteChar || "\"", this._handle.guessLineEndings(e, a)), e = [...e.split(t).slice(r)].join(t);
24
- }
25
- this.isFirstChunk && x(this._config.beforeFirstChunk) && (a = this._config.beforeFirstChunk(e)) !== void 0 && (e = a), this.isFirstChunk = !1, this._halted = !1;
26
- var r = this._partialLine + e, a = (this._partialLine = "", this._handle.parse(r, this._baseIndex, !this._finished));
27
- if (!this._handle.paused() && !this._handle.aborted()) {
28
- if (e = a.meta.cursor, r = (this._finished || (this._partialLine = r.substring(e - this._baseIndex), this._baseIndex = e), a && a.data && (this._rowCount += a.data.length), this._finished || this._config.preview && this._rowCount >= this._config.preview), i) t.postMessage({
29
- results: a,
30
- workerId: s.WORKER_ID,
31
- finished: r
32
- });
33
- else if (x(this._config.chunk) && !n) {
34
- if (this._config.chunk(a, this._handle), this._handle.paused() || this._handle.aborted()) return void (this._halted = !0);
35
- this._completeResults = a = void 0;
36
- }
37
- return this._config.step || this._config.chunk || (this._completeResults.data = this._completeResults.data.concat(a.data), this._completeResults.errors = this._completeResults.errors.concat(a.errors), this._completeResults.meta = a.meta), this._completed || !r || !x(this._config.complete) || a && a.meta.aborted || (this._config.complete(this._completeResults, this._input), this._completed = !0), r || a && a.meta.paused || this._nextChunk(), a;
38
- }
39
- this._halted = !0;
40
- }, this._sendError = function(e) {
41
- x(this._config.error) ? this._config.error(e) : i && this._config.error && t.postMessage({
42
- workerId: s.WORKER_ID,
43
- error: e,
44
- finished: !1
45
- });
46
- };
47
- }
48
- function l(e) {
49
- var t;
50
- (e ||= {}).chunkSize || (e.chunkSize = s.RemoteChunkSize), c.call(this, e), this._nextChunk = r ? function() {
51
- this._readChunk(), this._chunkLoaded();
52
- } : function() {
53
- this._readChunk();
54
- }, this.stream = function(e) {
55
- this._input = e, this._nextChunk();
56
- }, this._readChunk = function() {
57
- if (this._finished) this._chunkLoaded();
58
- else {
59
- if (t = new XMLHttpRequest(), this._config.withCredentials && (t.withCredentials = this._config.withCredentials), r || (t.onload = b(this._chunkLoaded, this), t.onerror = b(this._chunkError, this)), t.open(this._config.downloadRequestBody ? "POST" : "GET", this._input, !r), this._config.downloadRequestHeaders) {
60
- var e, n = this._config.downloadRequestHeaders;
61
- for (e in n) t.setRequestHeader(e, n[e]);
62
- }
63
- var i;
64
- this._config.chunkSize && (i = this._start + this._config.chunkSize - 1, t.setRequestHeader("Range", "bytes=" + this._start + "-" + i));
65
- try {
66
- t.send(this._config.downloadRequestBody);
67
- } catch (e) {
68
- this._chunkError(e.message);
69
- }
70
- r && t.status === 0 && this._chunkError();
71
- }
72
- }, this._chunkLoaded = function() {
73
- t.readyState === 4 && (t.status < 200 || 400 <= t.status ? this._chunkError() : (this._start += this._config.chunkSize || t.responseText.length, this._finished = !this._config.chunkSize || this._start >= ((e) => (e = e.getResponseHeader("Content-Range")) === null ? -1 : parseInt(e.substring(e.lastIndexOf("/") + 1)))(t), this.parseChunk(t.responseText)));
74
- }, this._chunkError = function(e) {
75
- e = t.statusText || e, this._sendError(Error(e));
76
- };
77
- }
78
- function u(e) {
79
- (e ||= {}).chunkSize || (e.chunkSize = s.LocalChunkSize), c.call(this, e);
80
- var t, n, r = typeof FileReader < "u";
81
- this.stream = function(e) {
82
- this._input = e, n = e.slice || e.webkitSlice || e.mozSlice, r ? ((t = new FileReader()).onload = b(this._chunkLoaded, this), t.onerror = b(this._chunkError, this)) : t = new FileReaderSync(), this._nextChunk();
83
- }, this._nextChunk = function() {
84
- this._finished || this._config.preview && !(this._rowCount < this._config.preview) || this._readChunk();
85
- }, this._readChunk = function() {
86
- var e = this._input, i = (this._config.chunkSize && (i = Math.min(this._start + this._config.chunkSize, this._input.size), e = n.call(e, this._start, i)), t.readAsText(e, this._config.encoding));
87
- r || this._chunkLoaded({ target: { result: i } });
88
- }, this._chunkLoaded = function(e) {
89
- this._start += this._config.chunkSize, this._finished = !this._config.chunkSize || this._start >= this._input.size, this.parseChunk(e.target.result);
90
- }, this._chunkError = function() {
91
- this._sendError(t.error);
92
- };
93
- }
94
- function d(e) {
95
- var t;
96
- c.call(this, e ||= {}), this.stream = function(e) {
97
- return t = e, this._nextChunk();
98
- }, this._nextChunk = function() {
99
- var e, n;
100
- if (!this._finished) return e = this._config.chunkSize, t = e ? (n = t.substring(0, e), t.substring(e)) : (n = t, ""), this._finished = !t, this.parseChunk(n);
101
- };
102
- }
103
- function f(e) {
104
- c.call(this, e ||= {});
105
- var t = [], n = !0, r = !1;
106
- this.pause = function() {
107
- c.prototype.pause.apply(this, arguments), this._input.pause();
108
- }, this.resume = function() {
109
- c.prototype.resume.apply(this, arguments), this._input.resume();
110
- }, this.stream = function(e) {
111
- this._input = e, this._input.on("data", this._streamData), this._input.on("end", this._streamEnd), this._input.on("error", this._streamError);
112
- }, this._checkIsFinished = function() {
113
- r && t.length === 1 && (this._finished = !0);
114
- }, this._nextChunk = function() {
115
- this._checkIsFinished(), t.length ? this.parseChunk(t.shift()) : n = !0;
116
- }, this._streamData = b(function(e) {
117
- try {
118
- t.push(typeof e == "string" ? e : e.toString(this._config.encoding)), n && (n = !1, this._checkIsFinished(), this.parseChunk(t.shift()));
119
- } catch (e) {
120
- this._streamError(e);
121
- }
122
- }, this), this._streamError = b(function(e) {
123
- this._streamCleanUp(), this._sendError(e);
124
- }, this), this._streamEnd = b(function() {
125
- this._streamCleanUp(), r = !0, this._streamData("");
126
- }, this), this._streamCleanUp = b(function() {
127
- this._input.removeListener("data", this._streamData), this._input.removeListener("end", this._streamEnd), this._input.removeListener("error", this._streamError);
128
- }, this);
129
- }
130
- function p(e) {
131
- var t, n, r, i, a = 2 ** 53, o = -a, c = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/, l = /^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/, u = this, d = 0, f = 0, p = !1, g = !1, _ = [], v = {
132
- data: [],
133
- errors: [],
134
- meta: {}
135
- };
136
- function b(t) {
137
- return e.skipEmptyLines === "greedy" ? t.join("").trim() === "" : t.length === 1 && t[0].length === 0;
138
- }
139
- function S() {
140
- if (v && r && (w("Delimiter", "UndetectableDelimiter", "Unable to auto-detect delimiting character; defaulted to '" + s.DefaultDelimiter + "'"), r = !1), e.skipEmptyLines && (v.data = v.data.filter(function(e) {
141
- return !b(e);
142
- })), C()) {
143
- if (v) {
144
- if (Array.isArray(v.data[0])) {
145
- for (var t = 0; C() && t < v.data.length; t++) v.data[t].forEach(n);
146
- v.data.splice(0, 1);
147
- } else v.data.forEach(n);
148
- }
149
- function n(t, n) {
150
- x(e.transformHeader) && (t = e.transformHeader(t, n)), _.push(t);
151
- }
152
- }
153
- function n(t, n) {
154
- for (var r = e.header ? {} : [], i = 0; i < t.length; i++) {
155
- var s = i, u = t[i], u = ((t, n) => ((t) => (e.dynamicTypingFunction && e.dynamicTyping[t] === void 0 && (e.dynamicTyping[t] = e.dynamicTypingFunction(t)), !0 === (e.dynamicTyping[t] || e.dynamicTyping)))(t) ? n === "true" || n === "TRUE" || n !== "false" && n !== "FALSE" && (((e) => {
156
- if (c.test(e) && (e = parseFloat(e), o < e && e < a)) return 1;
157
- })(n) ? parseFloat(n) : l.test(n) ? new Date(n) : n === "" ? null : n) : n)(s = e.header ? i >= _.length ? "__parsed_extra" : _[i] : s, u = e.transform ? e.transform(u, s) : u);
158
- s === "__parsed_extra" ? (r[s] = r[s] || [], r[s].push(u)) : r[s] = u;
159
- }
160
- return e.header && (i > _.length ? w("FieldMismatch", "TooManyFields", "Too many fields: expected " + _.length + " fields but parsed " + i, f + n) : i < _.length && w("FieldMismatch", "TooFewFields", "Too few fields: expected " + _.length + " fields but parsed " + i, f + n)), r;
161
- }
162
- var i;
163
- v && (e.header || e.dynamicTyping || e.transform) && (i = 1, !v.data.length || Array.isArray(v.data[0]) ? (v.data = v.data.map(n), i = v.data.length) : v.data = n(v.data, 0), e.header && v.meta && (v.meta.fields = _), f += i);
164
- }
165
- function C() {
166
- return e.header && _.length === 0;
167
- }
168
- function w(e, t, n, r) {
169
- e = {
170
- type: e,
171
- code: t,
172
- message: n
173
- }, r !== void 0 && (e.row = r), v.errors.push(e);
174
- }
175
- x(e.step) && (i = e.step, e.step = function(t) {
176
- v = t, C() ? S() : (S(), v.data.length !== 0 && (d += t.data.length, e.preview && d > e.preview ? n.abort() : (v.data = v.data[0], i(v, u))));
177
- }), this.parse = function(i, a, o) {
178
- var c = e.quoteChar || "\"", c = (e.newline ||= this.guessLineEndings(i, c), r = !1, e.delimiter ? x(e.delimiter) && (e.delimiter = e.delimiter(i), v.meta.delimiter = e.delimiter) : ((c = ((t, n, r, i, a) => {
179
- var o, c, l, u;
180
- a ||= [
181
- ",",
182
- " ",
183
- "|",
184
- ";",
185
- s.RECORD_SEP,
186
- s.UNIT_SEP
187
- ];
188
- for (var d = 0; d < a.length; d++) {
189
- for (var f, p = a[d], m = 0, g = 0, _ = 0, v = (l = void 0, new h({
190
- comments: i,
191
- delimiter: p,
192
- newline: n,
193
- preview: 10
194
- }).parse(t)), y = 0; y < v.data.length; y++) r && b(v.data[y]) ? _++ : (f = v.data[y].length, g += f, l === void 0 ? l = f : 0 < f && (m += Math.abs(f - l), l = f));
195
- 0 < v.data.length && (g /= v.data.length - _), (c === void 0 || m <= c) && (u === void 0 || u < g) && 1.99 < g && (c = m, o = p, u = g);
196
- }
197
- return {
198
- successful: !!(e.delimiter = o),
199
- bestDelimiter: o
200
- };
201
- })(i, e.newline, e.skipEmptyLines, e.comments, e.delimitersToGuess)).successful ? e.delimiter = c.bestDelimiter : (r = !0, e.delimiter = s.DefaultDelimiter), v.meta.delimiter = e.delimiter), y(e));
202
- return e.preview && e.header && c.preview++, t = i, n = new h(c), v = n.parse(t, a, o), S(), p ? { meta: { paused: !0 } } : v || { meta: { paused: !1 } };
203
- }, this.paused = function() {
204
- return p;
205
- }, this.pause = function() {
206
- p = !0, n.abort(), t = x(e.chunk) ? "" : t.substring(n.getCharIndex());
207
- }, this.resume = function() {
208
- u.streamer._halted ? (p = !1, u.streamer.parseChunk(t, !0)) : setTimeout(u.resume, 3);
209
- }, this.aborted = function() {
210
- return g;
211
- }, this.abort = function() {
212
- g = !0, n.abort(), v.meta.aborted = !0, x(e.complete) && e.complete(v), t = "";
213
- }, this.guessLineEndings = function(e, t) {
214
- e = e.substring(0, 1048576);
215
- var t = RegExp(m(t) + "([^]*?)" + m(t), "gm"), n = (e = e.replace(t, "")).split("\r"), t = e.split("\n"), e = 1 < t.length && t[0].length < n[0].length;
216
- if (n.length === 1 || e) return "\n";
217
- for (var r = 0, i = 0; i < n.length; i++) n[i][0] === "\n" && r++;
218
- return r >= n.length / 2 ? "\r\n" : "\r";
219
- };
220
- }
221
- function m(e) {
222
- return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
223
- }
224
- function h(e) {
225
- var t = (e ||= {}).delimiter, n = e.newline, r = e.comments, i = e.step, a = e.preview, o = e.fastMode, c = null, l = !1, u = e.quoteChar == null ? "\"" : e.quoteChar, d = u;
226
- if (e.escapeChar !== void 0 && (d = e.escapeChar), (typeof t != "string" || -1 < s.BAD_DELIMITERS.indexOf(t)) && (t = ","), r === t) throw Error("Comment character same as delimiter");
227
- !0 === r ? r = "#" : (typeof r != "string" || -1 < s.BAD_DELIMITERS.indexOf(r)) && (r = !1), n !== "\n" && n !== "\r" && n !== "\r\n" && (n = "\n");
228
- var f = 0, p = !1;
229
- this.parse = function(s, h, g) {
230
- if (typeof s != "string") throw Error("Input must be a string");
231
- var _ = s.length, v = t.length, y = n.length, b = r.length, S = x(i), C = [], w = [], T = [], E = f = 0;
232
- if (!s) return R();
233
- if (o || !1 !== o && s.indexOf(u) === -1) {
234
- for (var D = s.split(n), O = 0; O < D.length; O++) {
235
- if (T = D[O], f += T.length, O !== D.length - 1) f += n.length;
236
- else if (g) return R();
237
- if (!r || T.substring(0, b) !== r) {
238
- if (S) {
239
- if (C = [], P(T.split(t)), z(), p) return R();
240
- } else P(T.split(t));
241
- if (a && a <= O) return C = C.slice(0, a), R(!0);
242
- }
243
- }
244
- return R();
245
- }
246
- for (var k = s.indexOf(t, f), A = s.indexOf(n, f), j = new RegExp(m(d) + m(u), "g"), M = s.indexOf(u, f);;) if (s[f] === u) for (M = f, f++;;) {
247
- if ((M = s.indexOf(u, M + 1)) === -1) return g || w.push({
248
- type: "Quotes",
249
- code: "MissingQuotes",
250
- message: "Quoted field unterminated",
251
- row: C.length,
252
- index: f
253
- }), I();
254
- if (M === _ - 1) return I(s.substring(f, M).replace(j, u));
255
- if (u === d && s[M + 1] === d) M++;
256
- else if (u === d || M === 0 || s[M - 1] !== d) {
257
- k !== -1 && k < M + 1 && (k = s.indexOf(t, M + 1));
258
- var N = F((A = A !== -1 && A < M + 1 ? s.indexOf(n, M + 1) : A) === -1 ? k : Math.min(k, A));
259
- if (s.substr(M + 1 + N, v) === t) {
260
- T.push(s.substring(f, M).replace(j, u)), s[f = M + 1 + N + v] !== u && (M = s.indexOf(u, f)), k = s.indexOf(t, f), A = s.indexOf(n, f);
261
- break;
262
- }
263
- if (N = F(A), s.substring(M + 1 + N, M + 1 + N + y) === n) {
264
- if (T.push(s.substring(f, M).replace(j, u)), L(M + 1 + N + y), k = s.indexOf(t, f), M = s.indexOf(u, f), S && (z(), p)) return R();
265
- if (a && C.length >= a) return R(!0);
266
- break;
267
- }
268
- w.push({
269
- type: "Quotes",
270
- code: "InvalidQuotes",
271
- message: "Trailing quote on quoted field is malformed",
272
- row: C.length,
273
- index: f
274
- }), M++;
275
- }
276
- }
277
- else if (r && T.length === 0 && s.substring(f, f + b) === r) {
278
- if (A === -1) return R();
279
- f = A + y, A = s.indexOf(n, f), k = s.indexOf(t, f);
280
- } else if (k !== -1 && (k < A || A === -1)) T.push(s.substring(f, k)), f = k + v, k = s.indexOf(t, f);
281
- else {
282
- if (A === -1) break;
283
- if (T.push(s.substring(f, A)), L(A + y), S && (z(), p)) return R();
284
- if (a && C.length >= a) return R(!0);
285
- }
286
- return I();
287
- function P(e) {
288
- C.push(e), E = f;
289
- }
290
- function F(e) {
291
- var t = 0;
292
- return t = e !== -1 && (e = s.substring(M + 1, e)) && e.trim() === "" ? e.length : t;
293
- }
294
- function I(e) {
295
- return g || (e === void 0 && (e = s.substring(f)), T.push(e), f = _, P(T), S && z()), R();
296
- }
297
- function L(e) {
298
- f = e, P(T), T = [], A = s.indexOf(n, f);
299
- }
300
- function R(r) {
301
- if (e.header && !h && C.length && !l) {
302
- var i = C[0], a = Object.create(null), o = new Set(i);
303
- let t = !1;
304
- for (let n = 0; n < i.length; n++) {
305
- let r = i[n];
306
- if (a[r = x(e.transformHeader) ? e.transformHeader(r, n) : r]) {
307
- let e, s = a[r];
308
- for (; e = r + "_" + s, s++, o.has(e););
309
- o.add(e), i[n] = e, a[r]++, t = !0, (c = c === null ? {} : c)[e] = r;
310
- } else a[r] = 1, i[n] = r;
311
- o.add(r);
312
- }
313
- t && console.warn("Duplicate headers found and renamed."), l = !0;
314
- }
315
- return {
316
- data: C,
317
- errors: w,
318
- meta: {
319
- delimiter: t,
320
- linebreak: n,
321
- aborted: p,
322
- truncated: !!r,
323
- cursor: E + (h || 0),
324
- renamedHeaders: c
325
- }
326
- };
327
- }
328
- function z() {
329
- i(R()), C = [], w = [];
330
- }
331
- }, this.abort = function() {
332
- p = !0;
333
- }, this.getCharIndex = function() {
334
- return f;
335
- };
336
- }
337
- function g(e) {
338
- var t = e.data, n = a[t.workerId], r = !1;
339
- if (t.error) n.userError(t.error, t.file);
340
- else if (t.results && t.results.data) {
341
- var i = {
342
- abort: function() {
343
- r = !0, _(t.workerId, {
344
- data: [],
345
- errors: [],
346
- meta: { aborted: !0 }
347
- });
348
- },
349
- pause: v,
350
- resume: v
351
- };
352
- if (x(n.userStep)) {
353
- for (var o = 0; o < t.results.data.length && (n.userStep({
354
- data: t.results.data[o],
355
- errors: t.results.errors,
356
- meta: t.results.meta
357
- }, i), !r); o++);
358
- delete t.results;
359
- } else x(n.userChunk) && (n.userChunk(t.results, i, t.file), delete t.results);
360
- }
361
- t.finished && !r && _(t.workerId, t.results);
362
- }
363
- function _(e, t) {
364
- var n = a[e];
365
- x(n.userComplete) && n.userComplete(t), n.terminate(), delete a[e];
366
- }
367
- function v() {
368
- throw Error("Not implemented.");
369
- }
370
- function y(e) {
371
- if (typeof e != "object" || !e) return e;
372
- var t, n = Array.isArray(e) ? [] : {};
373
- for (t in e) n[t] = y(e[t]);
374
- return n;
375
- }
376
- function b(e, t) {
377
- return function() {
378
- e.apply(t, arguments);
379
- };
380
- }
381
- function x(e) {
382
- return typeof e == "function";
383
- }
384
- return s.parse = function(n, r) {
385
- var i = (r ||= {}).dynamicTyping || !1;
386
- if (x(i) && (r.dynamicTypingFunction = i, i = {}), r.dynamicTyping = i, r.transform = !!x(r.transform) && r.transform, !r.worker || !s.WORKERS_SUPPORTED) return i = null, s.NODE_STREAM_INPUT, typeof n == "string" ? (n = ((e) => e.charCodeAt(0) === 65279 ? e.slice(1) : e)(n), i = new (r.download ? l : d)(r)) : !0 === n.readable && x(n.read) && x(n.on) ? i = new f(r) : (t.File && n instanceof File || n instanceof Object) && (i = new u(r)), i.stream(n);
387
- (i = (() => {
388
- var n;
389
- return !!s.WORKERS_SUPPORTED && (n = (() => {
390
- var n = t.URL || t.webkitURL || null, r = e.toString();
391
- return s.BLOB_URL ||= n.createObjectURL(new Blob([
392
- "var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ",
393
- "(",
394
- r,
395
- ")();"
396
- ], { type: "text/javascript" }));
397
- })(), (n = new t.Worker(n)).onmessage = g, n.id = o++, a[n.id] = n);
398
- })()).userStep = r.step, i.userChunk = r.chunk, i.userComplete = r.complete, i.userError = r.error, r.step = x(r.step), r.chunk = x(r.chunk), r.complete = x(r.complete), r.error = x(r.error), delete r.worker, i.postMessage({
399
- input: n,
400
- config: r,
401
- workerId: i.id
402
- });
403
- }, s.unparse = function(e, t) {
404
- var n = !1, r = !0, i = ",", a = "\r\n", o = "\"", c = o + o, l = !1, u = null, d = !1, f = ((() => {
405
- if (typeof t == "object") {
406
- if (typeof t.delimiter != "string" || s.BAD_DELIMITERS.filter(function(e) {
407
- return t.delimiter.indexOf(e) !== -1;
408
- }).length || (i = t.delimiter), typeof t.quotes != "boolean" && typeof t.quotes != "function" && !Array.isArray(t.quotes) || (n = t.quotes), typeof t.skipEmptyLines != "boolean" && typeof t.skipEmptyLines != "string" || (l = t.skipEmptyLines), typeof t.newline == "string" && (a = t.newline), typeof t.quoteChar == "string" && (o = t.quoteChar), typeof t.header == "boolean" && (r = t.header), Array.isArray(t.columns)) {
409
- if (t.columns.length === 0) throw Error("Option columns is empty");
410
- u = t.columns;
411
- }
412
- t.escapeChar !== void 0 && (c = t.escapeChar + o), t.escapeFormulae instanceof RegExp ? d = t.escapeFormulae : typeof t.escapeFormulae == "boolean" && t.escapeFormulae && (d = /^[=+\-@\t\r].*$/);
413
- }
414
- })(), new RegExp(m(o), "g"));
415
- if (typeof e == "string" && (e = JSON.parse(e)), Array.isArray(e)) {
416
- if (!e.length || Array.isArray(e[0])) return p(null, e, l);
417
- if (typeof e[0] == "object") return p(u || Object.keys(e[0]), e, l);
418
- } else if (typeof e == "object") return typeof e.data == "string" && (e.data = JSON.parse(e.data)), Array.isArray(e.data) && (e.fields || (e.fields = e.meta && e.meta.fields || u), e.fields || (e.fields = Array.isArray(e.data[0]) ? e.fields : typeof e.data[0] == "object" ? Object.keys(e.data[0]) : []), Array.isArray(e.data[0]) || typeof e.data[0] == "object" || (e.data = [e.data])), p(e.fields || [], e.data || [], l);
419
- throw Error("Unable to serialize unrecognized input");
420
- function p(e, t, n) {
421
- var o = "", s = (typeof e == "string" && (e = JSON.parse(e)), typeof t == "string" && (t = JSON.parse(t)), Array.isArray(e) && 0 < e.length), c = !Array.isArray(t[0]);
422
- if (s && r) {
423
- for (var l = 0; l < e.length; l++) 0 < l && (o += i), o += h(e[l], l);
424
- 0 < t.length && (o += a);
425
- }
426
- for (var u = 0; u < t.length; u++) {
427
- var d = (s ? e : t[u]).length, f = !1, p = s ? Object.keys(t[u]).length === 0 : t[u].length === 0;
428
- if (n && !s && (f = n === "greedy" ? t[u].join("").trim() === "" : t[u].length === 1 && t[u][0].length === 0), n === "greedy" && s) {
429
- for (var m = [], g = 0; g < d; g++) {
430
- var _ = c ? e[g] : g;
431
- m.push(t[u][_]);
432
- }
433
- f = m.join("").trim() === "";
434
- }
435
- if (!f) {
436
- for (var v = 0; v < d; v++) {
437
- 0 < v && !p && (o += i);
438
- var y = s && c ? e[v] : v;
439
- o += h(t[u][y], v);
440
- }
441
- u < t.length - 1 && (!n || 0 < d && !p) && (o += a);
442
- }
443
- }
444
- return o;
445
- }
446
- function h(e, t) {
447
- var r, a;
448
- return e == null ? "" : e.constructor === Date ? JSON.stringify(e).slice(1, 25) : (a = !1, d && typeof e == "string" && d.test(e) && (e = "'" + e, a = !0), r = e.toString().replace(f, c), (a = a || !0 === n || typeof n == "function" && n(e, t) || Array.isArray(n) && n[t] || ((e, t) => {
449
- for (var n = 0; n < t.length; n++) if (-1 < e.indexOf(t[n])) return !0;
450
- return !1;
451
- })(r, s.BAD_DELIMITERS) || -1 < r.indexOf(i) || r.charAt(0) === " " || r.charAt(r.length - 1) === " ") ? o + r + o : r);
452
- }
453
- }, s.RECORD_SEP = "", s.UNIT_SEP = "", s.BYTE_ORDER_MARK = "", s.BAD_DELIMITERS = [
454
- "\r",
455
- "\n",
456
- "\"",
457
- s.BYTE_ORDER_MARK
458
- ], s.WORKERS_SUPPORTED = !r && !!t.Worker, s.NODE_STREAM_INPUT = 1, s.LocalChunkSize = 10485760, s.RemoteChunkSize = 5242880, s.DefaultDelimiter = ",", s.Parser = h, s.ParserHandle = p, s.NetworkStreamer = l, s.FileStreamer = u, s.StringStreamer = d, s.ReadableStreamStreamer = f, t.jQuery && ((n = t.jQuery).fn.parse = function(e) {
459
- var r = e.config || {}, i = [];
460
- return this.each(function(e) {
461
- if (!(n(this).prop("tagName").toUpperCase() === "INPUT" && n(this).attr("type").toLowerCase() === "file" && t.FileReader) || !this.files || this.files.length === 0) return !0;
462
- for (var a = 0; a < this.files.length; a++) i.push({
463
- file: this.files[a],
464
- inputElem: this,
465
- instanceConfig: n.extend({}, r)
466
- });
467
- }), a(), this;
468
- function a() {
469
- if (i.length === 0) x(e.complete) && e.complete();
470
- else {
471
- var t, r, a, c, l = i[0];
472
- if (x(e.before)) {
473
- var u = e.before(l.file, l.inputElem);
474
- if (typeof u == "object") {
475
- if (u.action === "abort") return t = "AbortError", r = l.file, a = l.inputElem, c = u.reason, void (x(e.error) && e.error({ name: t }, r, a, c));
476
- if (u.action === "skip") return void o();
477
- typeof u.config == "object" && (l.instanceConfig = n.extend(l.instanceConfig, u.config));
478
- } else if (u === "skip") return void o();
479
- }
480
- var d = l.instanceConfig.complete;
481
- l.instanceConfig.complete = function(e) {
482
- x(d) && d(e, l.file, l.inputElem), o();
483
- }, s.parse(l.file, l.instanceConfig);
484
- }
485
- }
486
- function o() {
487
- i.splice(0, 1), a();
488
- }
489
- }), i && (t.onmessage = function(e) {
490
- e = e.data, s.WORKER_ID === void 0 && e && (s.WORKER_ID = e.workerId), typeof e.input == "string" ? t.postMessage({
491
- workerId: s.WORKER_ID,
492
- results: s.parse(e.input, e.config),
493
- finished: !0
494
- }) : (t.File && e.input instanceof File || e.input instanceof Object) && (e = s.parse(e.input, e.config)) && t.postMessage({
495
- workerId: s.WORKER_ID,
496
- results: e,
497
- finished: !0
498
- });
499
- }), (l.prototype = Object.create(c.prototype)).constructor = l, (u.prototype = Object.create(c.prototype)).constructor = u, (d.prototype = Object.create(d.prototype)).constructor = d, (f.prototype = Object.create(c.prototype)).constructor = f, s;
500
- });
501
- })))(), 1);
502
- function c(e, t) {
503
- let n = e.findIndex((e) => e.toLowerCase() === t.toLowerCase());
504
- return n === -1 ? 0 : n;
505
- }
506
- function l(e) {
507
- return e.every((e) => e.length < 64);
508
- }
509
- function u(e) {
510
- return e.split(".").pop() || "";
511
- }
512
- function d(e) {
513
- switch (u(e)) {
514
- case "json": return "application/json";
515
- case "jsonl": return "application/jsonl";
516
- case "parquet": return "application/parquet";
517
- case "csv": return "text/csv";
518
- case "txt": return "text/plain";
519
- case "pdf": return "application/pdf";
520
- case "docx": return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
521
- case "zip": return "application/zip";
522
- default: return "unknown";
523
- }
524
- }
525
- async function f(e, t) {
526
- let u = e.type === "" ? e instanceof File ? d(e.name) : "application/zip" : e.type;
527
- if (u === "application/parquet") throw Error("unsupported_file_type");
528
- if (u === "application/pdf") return new i(await n(e, t?.maxSize));
529
- if (u === "application/vnd.openxmlformats-officedocument.wordprocessingml.document") return new i(await r(e));
530
- if (u === "application/json") {
531
- let t = await e.text(), n = JSON.parse(t);
532
- if (Array.isArray(n)) return new i(n.map((e) => [typeof e == "string" ? {
533
- role: "text",
534
- content: e
535
- } : "text" in e ? {
536
- role: "text",
537
- content: e.text
538
- } : {
539
- role: "text",
540
- content: JSON.stringify(e)
541
- }]));
542
- throw Error("bad_format");
543
- }
544
- if (u === "application/jsonl") return new o(e);
545
- if (u === "application/zip") return new a(e);
546
- if (u === "text/csv") {
547
- let n = await e.text();
548
- return new Promise((e, r) => {
549
- s.default.parse(n, {
550
- header: !1,
551
- skipEmptyLines: !0,
552
- delimiter: ",",
553
- complete: (n) => {
554
- if (n.errors.length > 0) console.error(n.errors), r(/* @__PURE__ */ Error("bad_format"));
555
- else {
556
- let r = c(n.data[0], t?.column || "text"), a = t?.hasHeader ?? l(n.data[0]) ? n.data.slice(1) : n.data;
557
- e(new i(a.map((e) => [{
558
- role: "text",
559
- content: e[r]
560
- }])));
561
- }
562
- },
563
- error: (e) => {
564
- r(e);
565
- }
566
- });
567
- });
568
- }
569
- if (u === "text/plain") return new i([[{
570
- role: "text",
571
- content: await e.text()
572
- }]]);
573
- throw Error("unsupported_file_type");
574
- }
575
- export { f as default };
@@ -1,11 +0,0 @@
1
- import { n as e } from "./rolldown-runtime-CwxnZyOB.js";
2
- import t from "./data/textLoader.js";
3
- import { n } from "./stream-BBe2apn4.js";
4
- import r from "./utilities/datasetID.js";
5
- // lib/data.ts
6
- var i = /* @__PURE__ */ e({
7
- MemoryConversationStream: () => n,
8
- generateDatasetID: () => r,
9
- loadTextData: () => t
10
- });
11
- export { i as t };
package/dist/data.js DELETED
@@ -1,5 +0,0 @@
1
- import e from "./utilities/datasetID.js";
2
- import { n as t } from "./stream-BBe2apn4.js";
3
- import n from "./data/textLoader.js";
4
- import "./data-CV_i_H6B.js";
5
- export { t as MemoryConversationStream, e as generateDatasetID, n as loadTextData };