@genai-fi/nanogpt 0.19.0 → 0.20.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 (482) hide show
  1. package/package.json +9 -10
  2. package/dist/Generator.d.ts +0 -82
  3. package/dist/Generator.js +0 -11941
  4. package/dist/RealDiv-CGwv0liw.js +0 -365
  5. package/dist/Reshape-BW__R4mZ.js +0 -79
  6. package/dist/Reshape-CPBkTIH2.js +0 -14
  7. package/dist/TeachableLLM.d.ts +0 -70
  8. package/dist/TeachableLLM.js +0 -273
  9. package/dist/Trainer.d.ts +0 -43
  10. package/dist/Trainer.js +0 -244
  11. package/dist/_commonjsHelpers-ByX85dGu.js +0 -33
  12. package/dist/axis_util-GTVlo58H.js +0 -55
  13. package/dist/backend.d.ts +0 -2
  14. package/dist/backend.js +0 -13
  15. package/dist/backend_util-GaFarB78.js +0 -425
  16. package/dist/backend_webgpu-BqASlsbV.js +0 -545
  17. package/dist/binary_op_util-pKXltfxI.js +0 -192
  18. package/dist/broadcast_to-eS93CCN_.js +0 -28
  19. package/dist/checks/appendCache.d.ts +0 -1
  20. package/dist/checks/appendCache.js +0 -22
  21. package/dist/checks/attentionMask.d.ts +0 -1
  22. package/dist/checks/attentionMask.js +0 -37
  23. package/dist/checks/check.d.ts +0 -9
  24. package/dist/checks/check.js +0 -20
  25. package/dist/checks/gelu.d.ts +0 -1
  26. package/dist/checks/gelu.js +0 -18
  27. package/dist/checks/index.d.ts +0 -26
  28. package/dist/checks/index.js +0 -28
  29. package/dist/checks/matMulGelu.d.ts +0 -1
  30. package/dist/checks/matMulGelu.js +0 -28
  31. package/dist/checks/normRMS.d.ts +0 -1
  32. package/dist/checks/normRMS.js +0 -16
  33. package/dist/checks/normRMSGrad.d.ts +0 -1
  34. package/dist/checks/normRMSGrad.js +0 -12
  35. package/dist/checks/packUnpack.d.ts +0 -1
  36. package/dist/checks/packUnpack.js +0 -18
  37. package/dist/checks/qkv.d.ts +0 -1
  38. package/dist/checks/qkv.js +0 -34
  39. package/dist/checks/rope.d.ts +0 -1
  40. package/dist/checks/rope.js +0 -36
  41. package/dist/checks/weights.d.ts +0 -14
  42. package/dist/checks/weights.js +0 -31
  43. package/dist/clip_by_value-DDA7rrcT.js +0 -12
  44. package/dist/complex-DI35Q-gW.js +0 -11
  45. package/dist/complex_util-Yc1A_gV1.js +0 -55
  46. package/dist/concat-CAQpCret.js +0 -17
  47. package/dist/concat_util-D18dJ4fD.js +0 -22
  48. package/dist/data/docx.d.ts +0 -2
  49. package/dist/data/docx.js +0 -15
  50. package/dist/data/parquet.d.ts +0 -2
  51. package/dist/data/parquet.js +0 -17
  52. package/dist/data/pdf.d.ts +0 -2
  53. package/dist/data/pdf.js +0 -14
  54. package/dist/data/textLoader.d.ts +0 -7
  55. package/dist/data/textLoader.js +0 -108
  56. package/dist/dataset-CGGp1z9P.js +0 -1124
  57. package/dist/dropout_util--NxWuYg2.js +0 -27
  58. package/dist/expand_dims-Bkd1YD5x.js +0 -11
  59. package/dist/exports_initializers-CYzKLjN7.js +0 -7
  60. package/dist/floor-BQtb-Azg.js +0 -9
  61. package/dist/gather-qIqEqaGn.js +0 -9
  62. package/dist/gelu-B220X1Go.js +0 -26
  63. package/dist/gpgpu_math-BwvV12df.js +0 -2022
  64. package/dist/index-CUXkjxiT.js +0 -3516
  65. package/dist/index-CieiGp4Y.js +0 -349
  66. package/dist/index-CjOWnMXP.js +0 -7308
  67. package/dist/index-Cp39cXWe.js +0 -1016
  68. package/dist/index-D5v913EJ.js +0 -4
  69. package/dist/index-DmeWGGmS.js +0 -1074
  70. package/dist/index-DvYrXKkX.js +0 -113
  71. package/dist/index-Ksja3su6.js +0 -151
  72. package/dist/index-xuotMAFm.js +0 -118
  73. package/dist/inference/types.d.ts +0 -16
  74. package/dist/inference/types.js +0 -1
  75. package/dist/jszip.min-BZhlzntC.js +0 -2313
  76. package/dist/kernel_funcs_utils-pq0CK9co.js +0 -306
  77. package/dist/layers/BaseLayer.d.ts +0 -44
  78. package/dist/layers/BaseLayer.js +0 -74
  79. package/dist/layers/CausalSelfAttention.d.ts +0 -39
  80. package/dist/layers/CausalSelfAttention.js +0 -86
  81. package/dist/layers/LoRA.d.ts +0 -14
  82. package/dist/layers/LoRA.js +0 -58
  83. package/dist/layers/MLP.d.ts +0 -17
  84. package/dist/layers/MLP.js +0 -44
  85. package/dist/layers/PositionEmbedding.d.ts +0 -8
  86. package/dist/layers/PositionEmbedding.js +0 -31
  87. package/dist/layers/RMSNorm.d.ts +0 -12
  88. package/dist/layers/RMSNorm.js +0 -22
  89. package/dist/layers/RoPECache.d.ts +0 -18
  90. package/dist/layers/RoPECache.js +0 -50
  91. package/dist/layers/TiedEmbedding.d.ts +0 -13
  92. package/dist/layers/TiedEmbedding.js +0 -36
  93. package/dist/layers/TransformerBlock.d.ts +0 -27
  94. package/dist/layers/TransformerBlock.js +0 -40
  95. package/dist/layers/WeightStore.d.ts +0 -20
  96. package/dist/layers/WeightStore.js +0 -76
  97. package/dist/loader/load.d.ts +0 -6
  98. package/dist/loader/load.js +0 -68
  99. package/dist/loader/loadHF.d.ts +0 -8
  100. package/dist/loader/loadHF.js +0 -22
  101. package/dist/loader/loadTransformers.d.ts +0 -4
  102. package/dist/loader/loadTransformers.js +0 -44
  103. package/dist/loader/loadZipMeta.d.ts +0 -3
  104. package/dist/loader/loadZipMeta.js +0 -16
  105. package/dist/loader/newZipLoad.d.ts +0 -3
  106. package/dist/loader/newZipLoad.js +0 -31
  107. package/dist/loader/oldZipLoad.d.ts +0 -9
  108. package/dist/loader/oldZipLoad.js +0 -80
  109. package/dist/loader/save.d.ts +0 -16
  110. package/dist/loader/save.js +0 -90
  111. package/dist/loader/types.d.ts +0 -67
  112. package/dist/loader/types.js +0 -1
  113. package/dist/main.d.ts +0 -50
  114. package/dist/main.js +0 -109
  115. package/dist/matMul16-BcVC_E62.js +0 -80
  116. package/dist/matMulGelu-JNLZqKQp.js +0 -163
  117. package/dist/mat_mul-DhG0Newp.js +0 -11
  118. package/dist/mod-CSdCpRjf.js +0 -11
  119. package/dist/models/NanoGPTV1.d.ts +0 -16
  120. package/dist/models/NanoGPTV1.js +0 -99
  121. package/dist/models/NanoGPTV2.d.ts +0 -16
  122. package/dist/models/NanoGPTV2.js +0 -90
  123. package/dist/models/config.d.ts +0 -27
  124. package/dist/models/config.js +0 -50
  125. package/dist/models/factory.d.ts +0 -3
  126. package/dist/models/factory.js +0 -16
  127. package/dist/models/model.d.ts +0 -44
  128. package/dist/models/model.js +0 -134
  129. package/dist/non_max_suppression_impl-B2W7YjZB.js +0 -102
  130. package/dist/not_equal-hurPF26l.js +0 -64
  131. package/dist/ones-BytntneX.js +0 -14
  132. package/dist/ops/adamAdjust.d.ts +0 -2
  133. package/dist/ops/adamAdjust.js +0 -9
  134. package/dist/ops/adamMoments.d.ts +0 -2
  135. package/dist/ops/adamMoments.js +0 -9
  136. package/dist/ops/add16.d.ts +0 -2
  137. package/dist/ops/add16.js +0 -9
  138. package/dist/ops/appendCache.d.ts +0 -2
  139. package/dist/ops/appendCache.js +0 -22
  140. package/dist/ops/attentionMask.d.ts +0 -2
  141. package/dist/ops/attentionMask.js +0 -10
  142. package/dist/ops/concat16.d.ts +0 -2
  143. package/dist/ops/concat16.js +0 -9
  144. package/dist/ops/cpu/adamAdjust.d.ts +0 -1
  145. package/dist/ops/cpu/adamAdjust.js +0 -18
  146. package/dist/ops/cpu/adamMoments.d.ts +0 -1
  147. package/dist/ops/cpu/adamMoments.js +0 -16
  148. package/dist/ops/cpu/appendCache.d.ts +0 -1
  149. package/dist/ops/cpu/appendCache.js +0 -23
  150. package/dist/ops/cpu/attentionMask.d.ts +0 -1
  151. package/dist/ops/cpu/attentionMask.js +0 -22
  152. package/dist/ops/cpu/fusedSoftmax.d.ts +0 -9
  153. package/dist/ops/cpu/fusedSoftmax.js +0 -29
  154. package/dist/ops/cpu/gatherSub.d.ts +0 -1
  155. package/dist/ops/cpu/gatherSub.js +0 -18
  156. package/dist/ops/cpu/gelu.d.ts +0 -1
  157. package/dist/ops/cpu/gelu.js +0 -40
  158. package/dist/ops/cpu/matMul16.d.ts +0 -1
  159. package/dist/ops/cpu/matMul16.js +0 -15
  160. package/dist/ops/cpu/matMulGelu.d.ts +0 -1
  161. package/dist/ops/cpu/matMulGelu.js +0 -53
  162. package/dist/ops/cpu/matMulMul.d.ts +0 -1
  163. package/dist/ops/cpu/matMulMul.js +0 -23
  164. package/dist/ops/cpu/mulDropout.d.ts +0 -1
  165. package/dist/ops/cpu/mulDropout.js +0 -23
  166. package/dist/ops/cpu/normRMS.d.ts +0 -1
  167. package/dist/ops/cpu/normRMS.js +0 -39
  168. package/dist/ops/cpu/qkv.d.ts +0 -5
  169. package/dist/ops/cpu/qkv.js +0 -41
  170. package/dist/ops/cpu/rope.d.ts +0 -6
  171. package/dist/ops/cpu/rope.js +0 -38
  172. package/dist/ops/cpu/scatterSub.d.ts +0 -1
  173. package/dist/ops/cpu/scatterSub.js +0 -23
  174. package/dist/ops/dot16.d.ts +0 -2
  175. package/dist/ops/dot16.js +0 -42
  176. package/dist/ops/dropout.d.ts +0 -2
  177. package/dist/ops/dropout.js +0 -14
  178. package/dist/ops/dropout16.d.ts +0 -2
  179. package/dist/ops/dropout16.js +0 -25
  180. package/dist/ops/gatherSub.d.ts +0 -2
  181. package/dist/ops/gatherSub.js +0 -9
  182. package/dist/ops/gelu.d.ts +0 -3
  183. package/dist/ops/gelu.js +0 -8
  184. package/dist/ops/globalNorm.d.ts +0 -2
  185. package/dist/ops/globalNorm.js +0 -13
  186. package/dist/ops/grads/add16.d.ts +0 -1
  187. package/dist/ops/grads/add16.js +0 -26
  188. package/dist/ops/grads/attentionMask.d.ts +0 -1
  189. package/dist/ops/grads/attentionMask.js +0 -21
  190. package/dist/ops/grads/dropout16.d.ts +0 -1
  191. package/dist/ops/grads/dropout16.js +0 -2
  192. package/dist/ops/grads/gelu.d.ts +0 -2
  193. package/dist/ops/grads/gelu.js +0 -5
  194. package/dist/ops/grads/matMul16.d.ts +0 -2
  195. package/dist/ops/grads/matMul16.js +0 -9
  196. package/dist/ops/grads/matMulGelu.d.ts +0 -1
  197. package/dist/ops/grads/matMulGelu.js +0 -17
  198. package/dist/ops/grads/mul16.d.ts +0 -1
  199. package/dist/ops/grads/mul16.js +0 -4
  200. package/dist/ops/grads/normRMS.d.ts +0 -3
  201. package/dist/ops/grads/normRMS.js +0 -33
  202. package/dist/ops/grads/pack16.d.ts +0 -2
  203. package/dist/ops/grads/pack16.js +0 -6
  204. package/dist/ops/grads/qkv.d.ts +0 -3
  205. package/dist/ops/grads/qkv.js +0 -34
  206. package/dist/ops/grads/rope.d.ts +0 -2
  207. package/dist/ops/grads/rope.js +0 -5
  208. package/dist/ops/grads/softmax16.d.ts +0 -2
  209. package/dist/ops/grads/softmax16.js +0 -25
  210. package/dist/ops/grads/unpack16.d.ts +0 -2
  211. package/dist/ops/grads/unpack16.js +0 -5
  212. package/dist/ops/grads/utils.d.ts +0 -4
  213. package/dist/ops/grads/utils.js +0 -14
  214. package/dist/ops/log.d.ts +0 -0
  215. package/dist/ops/log.js +0 -1
  216. package/dist/ops/matMul16.d.ts +0 -15
  217. package/dist/ops/matMul16.js +0 -13
  218. package/dist/ops/matMulGelu.d.ts +0 -3
  219. package/dist/ops/matMulGelu.js +0 -14
  220. package/dist/ops/matMulMul.d.ts +0 -2
  221. package/dist/ops/matMulMul.js +0 -9
  222. package/dist/ops/mul16.d.ts +0 -2
  223. package/dist/ops/mul16.js +0 -39
  224. package/dist/ops/mulDrop.d.ts +0 -2
  225. package/dist/ops/mulDrop.js +0 -9
  226. package/dist/ops/normRMS.d.ts +0 -2
  227. package/dist/ops/normRMS.js +0 -19
  228. package/dist/ops/pack16.d.ts +0 -2
  229. package/dist/ops/pack16.js +0 -5
  230. package/dist/ops/qkv.d.ts +0 -2
  231. package/dist/ops/qkv.js +0 -10
  232. package/dist/ops/reshape16.d.ts +0 -2
  233. package/dist/ops/reshape16.js +0 -41
  234. package/dist/ops/rope.d.ts +0 -3
  235. package/dist/ops/rope.js +0 -7
  236. package/dist/ops/scatterSub.d.ts +0 -2
  237. package/dist/ops/scatterSub.js +0 -9
  238. package/dist/ops/slice16.d.ts +0 -2
  239. package/dist/ops/slice16.js +0 -9
  240. package/dist/ops/softmax16.d.ts +0 -2
  241. package/dist/ops/softmax16.js +0 -9
  242. package/dist/ops/sub16.d.ts +0 -2
  243. package/dist/ops/sub16.js +0 -8
  244. package/dist/ops/sum16.d.ts +0 -2
  245. package/dist/ops/sum16.js +0 -13
  246. package/dist/ops/transpose16.d.ts +0 -3
  247. package/dist/ops/transpose16.js +0 -40
  248. package/dist/ops/unpack16.d.ts +0 -2
  249. package/dist/ops/unpack16.js +0 -6
  250. package/dist/ops/webgl/adamAdjust.d.ts +0 -1
  251. package/dist/ops/webgl/adamAdjust.js +0 -49
  252. package/dist/ops/webgl/adamMoments.d.ts +0 -1
  253. package/dist/ops/webgl/adamMoments.js +0 -40
  254. package/dist/ops/webgl/appendCache.d.ts +0 -1
  255. package/dist/ops/webgl/appendCache.js +0 -44
  256. package/dist/ops/webgl/attentionMask.d.ts +0 -1
  257. package/dist/ops/webgl/attentionMask.js +0 -45
  258. package/dist/ops/webgl/dropout16.d.ts +0 -1
  259. package/dist/ops/webgl/dropout16.js +0 -11
  260. package/dist/ops/webgl/fusedSoftmax.d.ts +0 -11
  261. package/dist/ops/webgl/fusedSoftmax.js +0 -80
  262. package/dist/ops/webgl/gatherSub.d.ts +0 -1
  263. package/dist/ops/webgl/gatherSub.js +0 -27
  264. package/dist/ops/webgl/gelu.d.ts +0 -2
  265. package/dist/ops/webgl/gelu.js +0 -50
  266. package/dist/ops/webgl/log.d.ts +0 -17
  267. package/dist/ops/webgl/log.js +0 -23
  268. package/dist/ops/webgl/matMul16.d.ts +0 -1
  269. package/dist/ops/webgl/matMul16.js +0 -45
  270. package/dist/ops/webgl/matMulGelu.d.ts +0 -21
  271. package/dist/ops/webgl/matMulGelu.js +0 -9
  272. package/dist/ops/webgl/matMulMul.d.ts +0 -14
  273. package/dist/ops/webgl/matMulMul.js +0 -28
  274. package/dist/ops/webgl/mulDropout.d.ts +0 -1
  275. package/dist/ops/webgl/mulDropout.js +0 -41
  276. package/dist/ops/webgl/normRMS.d.ts +0 -1
  277. package/dist/ops/webgl/normRMS.js +0 -93
  278. package/dist/ops/webgl/qkv.d.ts +0 -1
  279. package/dist/ops/webgl/qkv.js +0 -46
  280. package/dist/ops/webgl/rope.d.ts +0 -1
  281. package/dist/ops/webgl/rope.js +0 -56
  282. package/dist/ops/webgl/scatterSub.d.ts +0 -1
  283. package/dist/ops/webgl/scatterSub.js +0 -27
  284. package/dist/ops/webgpu/adamAdjust.d.ts +0 -1
  285. package/dist/ops/webgpu/adamAdjust.js +0 -57
  286. package/dist/ops/webgpu/adamMoments.d.ts +0 -1
  287. package/dist/ops/webgpu/adamMoments.js +0 -60
  288. package/dist/ops/webgpu/add16.d.ts +0 -1
  289. package/dist/ops/webgpu/add16.js +0 -13
  290. package/dist/ops/webgpu/appendCache.d.ts +0 -1
  291. package/dist/ops/webgpu/appendCache.js +0 -105
  292. package/dist/ops/webgpu/attentionMask.d.ts +0 -1
  293. package/dist/ops/webgpu/attentionMask.js +0 -26
  294. package/dist/ops/webgpu/attentionMask32_program.d.ts +0 -19
  295. package/dist/ops/webgpu/attentionMask32_program.js +0 -54
  296. package/dist/ops/webgpu/clipScale.d.ts +0 -1
  297. package/dist/ops/webgpu/clipScale.js +0 -58
  298. package/dist/ops/webgpu/concat16.d.ts +0 -19
  299. package/dist/ops/webgpu/concat16.js +0 -126
  300. package/dist/ops/webgpu/dropout16.d.ts +0 -1
  301. package/dist/ops/webgpu/dropout16.js +0 -51
  302. package/dist/ops/webgpu/gatherSub.d.ts +0 -1
  303. package/dist/ops/webgpu/gatherSub.js +0 -39
  304. package/dist/ops/webgpu/gelu.d.ts +0 -14
  305. package/dist/ops/webgpu/gelu.js +0 -141
  306. package/dist/ops/webgpu/index.d.ts +0 -0
  307. package/dist/ops/webgpu/index.js +0 -26
  308. package/dist/ops/webgpu/matMul16.d.ts +0 -1
  309. package/dist/ops/webgpu/matMul16.js +0 -65
  310. package/dist/ops/webgpu/matMul16_program.d.ts +0 -42
  311. package/dist/ops/webgpu/matMul16_program.js +0 -343
  312. package/dist/ops/webgpu/mul16.d.ts +0 -1
  313. package/dist/ops/webgpu/mul16.js +0 -13
  314. package/dist/ops/webgpu/norm2.d.ts +0 -1
  315. package/dist/ops/webgpu/norm2.js +0 -76
  316. package/dist/ops/webgpu/normRMS.d.ts +0 -1
  317. package/dist/ops/webgpu/normRMS.js +0 -34
  318. package/dist/ops/webgpu/normRMS16_program.d.ts +0 -10
  319. package/dist/ops/webgpu/normRMS16_program.js +0 -25
  320. package/dist/ops/webgpu/normRMS32_program.d.ts +0 -10
  321. package/dist/ops/webgpu/normRMS32_program.js +0 -25
  322. package/dist/ops/webgpu/normRMSGrad.d.ts +0 -1
  323. package/dist/ops/webgpu/normRMSGrad.js +0 -284
  324. package/dist/ops/webgpu/pack16.d.ts +0 -1
  325. package/dist/ops/webgpu/pack16.js +0 -18
  326. package/dist/ops/webgpu/pack16_program.d.ts +0 -19
  327. package/dist/ops/webgpu/pack16_program.js +0 -92
  328. package/dist/ops/webgpu/qkv.d.ts +0 -1
  329. package/dist/ops/webgpu/qkv.js +0 -24
  330. package/dist/ops/webgpu/rope.d.ts +0 -1
  331. package/dist/ops/webgpu/rope.js +0 -135
  332. package/dist/ops/webgpu/scatterSub.d.ts +0 -1
  333. package/dist/ops/webgpu/scatterSub.js +0 -40
  334. package/dist/ops/webgpu/slice16.d.ts +0 -7
  335. package/dist/ops/webgpu/slice16.js +0 -69
  336. package/dist/ops/webgpu/softmax16.d.ts +0 -17
  337. package/dist/ops/webgpu/softmax16.js +0 -21
  338. package/dist/ops/webgpu/softmax16_program.d.ts +0 -13
  339. package/dist/ops/webgpu/softmax16_program.js +0 -73
  340. package/dist/ops/webgpu/softmax16_subgroup_program.d.ts +0 -17
  341. package/dist/ops/webgpu/softmax16_subgroup_program.js +0 -75
  342. package/dist/ops/webgpu/softmax16grad.d.ts +0 -1
  343. package/dist/ops/webgpu/softmax16grad.js +0 -37
  344. package/dist/ops/webgpu/sub16.d.ts +0 -1
  345. package/dist/ops/webgpu/sub16.js +0 -13
  346. package/dist/ops/webgpu/sum16.d.ts +0 -1
  347. package/dist/ops/webgpu/sum16.js +0 -38
  348. package/dist/ops/webgpu/transpose16.d.ts +0 -1
  349. package/dist/ops/webgpu/transpose16.js +0 -34
  350. package/dist/ops/webgpu/transpose16_program.d.ts +0 -16
  351. package/dist/ops/webgpu/transpose16_program.js +0 -50
  352. package/dist/ops/webgpu/transpose16_shared_program.d.ts +0 -15
  353. package/dist/ops/webgpu/transpose16_shared_program.js +0 -70
  354. package/dist/ops/webgpu/unpack16.d.ts +0 -1
  355. package/dist/ops/webgpu/unpack16.js +0 -48
  356. package/dist/ops/webgpu/utils/binary_op.d.ts +0 -35
  357. package/dist/ops/webgpu/utils/binary_op.js +0 -139
  358. package/dist/ops/webgpu/utils/deviceInfo.d.ts +0 -7
  359. package/dist/ops/webgpu/utils/deviceInfo.js +0 -11
  360. package/dist/ops/webgpu/utils/reductions.d.ts +0 -43
  361. package/dist/ops/webgpu/utils/reductions.js +0 -275
  362. package/dist/ops-CsXeTq1P.js +0 -476
  363. package/dist/pack16-bqltoUlR.js +0 -39
  364. package/dist/papaparse.min-C0cScC2i.js +0 -418
  365. package/dist/parquet-Bqjmp2vo.js +0 -44231
  366. package/dist/patches/webgpu_backend.d.ts +0 -18
  367. package/dist/patches/webgpu_backend.js +0 -56
  368. package/dist/patches/webgpu_base.d.ts +0 -21
  369. package/dist/patches/webgpu_base.js +0 -34
  370. package/dist/patches/webgpu_program.d.ts +0 -36
  371. package/dist/patches/webgpu_program.js +0 -400
  372. package/dist/pdf-NIhmP3sq.js +0 -19477
  373. package/dist/rand_util-CZ7yLoUm.js +0 -50
  374. package/dist/random_normal-IBRrha8a.js +0 -14
  375. package/dist/random_width-DN5ZtQkM.js +0 -9796
  376. package/dist/range-C-CjF-LI.js +0 -10
  377. package/dist/relu-J_X6MUzx.js +0 -9
  378. package/dist/reshape-BDOuCSNW.js +0 -9
  379. package/dist/resize_nearest_neighbor-BojqlfRe.js +0 -150
  380. package/dist/rope-DcrZM_e6.js +0 -24
  381. package/dist/scatter_nd_util-ByNJaL6I.js +0 -46
  382. package/dist/segment_util-Dasb2Zaf.js +0 -43
  383. package/dist/selu_util-BLhIqRkw.js +0 -44
  384. package/dist/shared-3agzAqQ_.js +0 -53
  385. package/dist/shared-CagdqkLh.js +0 -2143
  386. package/dist/slice-BzS11Qh0.js +0 -12
  387. package/dist/slice_util-CC35pLmT.js +0 -153
  388. package/dist/softmax-D4q1LJN7.js +0 -12
  389. package/dist/split-C2Sj255c.js +0 -9
  390. package/dist/squeeze-ho4wLUek.js +0 -10
  391. package/dist/stack-DudVrtmG.js +0 -11
  392. package/dist/step-BTxPtq1r.js +0 -261
  393. package/dist/sum-BpiwSWvg.js +0 -11
  394. package/dist/tensor-BWFldCso.js +0 -8
  395. package/dist/tensor1d-LMGMIUlr.js +0 -11
  396. package/dist/tensor2d-BnXMKScO.js +0 -14
  397. package/dist/tensor4d-C6UCG_u8.js +0 -14
  398. package/dist/tfjs_backend-BGnG-ppu.js +0 -654
  399. package/dist/tile-CFy-xTO6.js +0 -11
  400. package/dist/tokeniser/BaseTokeniser.d.ts +0 -33
  401. package/dist/tokeniser/BaseTokeniser.js +0 -124
  402. package/dist/tokeniser/CharTokeniser.d.ts +0 -24
  403. package/dist/tokeniser/CharTokeniser.js +0 -107
  404. package/dist/tokeniser/bpe.d.ts +0 -28
  405. package/dist/tokeniser/bpe.js +0 -173
  406. package/dist/tokeniser/messages.d.ts +0 -61
  407. package/dist/tokeniser/messages.js +0 -1
  408. package/dist/tokeniser/type.d.ts +0 -34
  409. package/dist/tokeniser/type.js +0 -1
  410. package/dist/training/AdamW.d.ts +0 -36
  411. package/dist/training/AdamW.js +0 -138
  412. package/dist/training/BasicTrainer.d.ts +0 -63
  413. package/dist/training/BasicTrainer.js +0 -265
  414. package/dist/training/DatasetBuilder.d.ts +0 -26
  415. package/dist/training/DatasetBuilder.js +0 -86
  416. package/dist/training/Evaluator.d.ts +0 -19
  417. package/dist/training/Evaluator.js +0 -39
  418. package/dist/training/LRScheduler.d.ts +0 -12
  419. package/dist/training/LRScheduler.js +0 -34
  420. package/dist/training/PreTrainer.d.ts +0 -11
  421. package/dist/training/PreTrainer.js +0 -20
  422. package/dist/training/SFTTrainer.d.ts +0 -12
  423. package/dist/training/SFTTrainer.js +0 -22
  424. package/dist/training/loss.d.ts +0 -3
  425. package/dist/training/loss.js +0 -24
  426. package/dist/training/orthoGrad.d.ts +0 -2
  427. package/dist/training/orthoGrad.js +0 -10
  428. package/dist/training/sparseCrossEntropy.d.ts +0 -7
  429. package/dist/training/sparseCrossEntropy.js +0 -69
  430. package/dist/training/tasks/ConversationTask.d.ts +0 -18
  431. package/dist/training/tasks/ConversationTask.js +0 -40
  432. package/dist/training/tasks/PretrainingTask.d.ts +0 -17
  433. package/dist/training/tasks/PretrainingTask.js +0 -47
  434. package/dist/training/tasks/StartSentenceTask.d.ts +0 -18
  435. package/dist/training/tasks/StartSentenceTask.js +0 -49
  436. package/dist/training/tasks/Task.d.ts +0 -22
  437. package/dist/training/tasks/Task.js +0 -68
  438. package/dist/training/tasks/splitter.d.ts +0 -5
  439. package/dist/training/tasks/splitter.js +0 -21
  440. package/dist/training/types.d.ts +0 -78
  441. package/dist/training/types.js +0 -1
  442. package/dist/training/validation.d.ts +0 -17
  443. package/dist/training/validation.js +0 -84
  444. package/dist/transpose-9kRxIXWR.js +0 -36
  445. package/dist/unsorted_segment_sum-DJvk5xnh.js +0 -277
  446. package/dist/utilities/arrayClose.d.ts +0 -1
  447. package/dist/utilities/arrayClose.js +0 -20
  448. package/dist/utilities/datasetID.d.ts +0 -2
  449. package/dist/utilities/datasetID.js +0 -21
  450. package/dist/utilities/dummy.d.ts +0 -9
  451. package/dist/utilities/dummy.js +0 -43
  452. package/dist/utilities/multinomialCPU.d.ts +0 -2
  453. package/dist/utilities/multinomialCPU.js +0 -13
  454. package/dist/utilities/naming.d.ts +0 -4
  455. package/dist/utilities/naming.js +0 -1
  456. package/dist/utilities/packed.d.ts +0 -4
  457. package/dist/utilities/packed.js +0 -15
  458. package/dist/utilities/parameters.d.ts +0 -11
  459. package/dist/utilities/parameters.js +0 -57
  460. package/dist/utilities/performance.d.ts +0 -2
  461. package/dist/utilities/performance.js +0 -16
  462. package/dist/utilities/profile.d.ts +0 -17
  463. package/dist/utilities/profile.js +0 -38
  464. package/dist/utilities/safetensors.d.ts +0 -3
  465. package/dist/utilities/safetensors.js +0 -83
  466. package/dist/utilities/sentences.d.ts +0 -5
  467. package/dist/utilities/sentences.js +0 -41
  468. package/dist/utilities/tokenParse.d.ts +0 -1
  469. package/dist/utilities/tokenParse.js +0 -21
  470. package/dist/utilities/topP.d.ts +0 -1
  471. package/dist/utilities/topP.js +0 -13
  472. package/dist/utilities/waitForModel.d.ts +0 -2
  473. package/dist/utilities/waitForModel.js +0 -12
  474. package/dist/utilities/weights.d.ts +0 -12
  475. package/dist/utilities/weights.js +0 -45
  476. package/dist/utilities/yielder.d.ts +0 -1
  477. package/dist/utilities/yielder.js +0 -7
  478. package/dist/variable-Ck482e3n.js +0 -7
  479. package/dist/webgpu_program-B4HmApL1.js +0 -525
  480. package/dist/webgpu_util-DYlGSwOJ.js +0 -64
  481. package/dist/zeros-DvZpK8s6.js +0 -13
  482. package/dist/zeros_like-CWjDdwr-.js +0 -721
@@ -1,8 +0,0 @@
1
- import { Tensor } from '@tensorflow/tfjs-core';
2
- import { default as BaseLayer } from './BaseLayer';
3
- import { GPTConfig, ModelForwardAttributes } from '../main';
4
- export default class PositionEmbedding extends BaseLayer {
5
- private wpe?;
6
- constructor(config: GPTConfig, name?: string, parent?: BaseLayer);
7
- forward(attrs: ModelForwardAttributes, x: Tensor): Tensor;
8
- }
@@ -1,31 +0,0 @@
1
- import { t as c, an as p, a as s } from "../index-CUXkjxiT.js";
2
- import f from "./BaseLayer.js";
3
- import { E as u } from "../random_width-DN5ZtQkM.js";
4
- import { r as b } from "../exports_initializers-CYzKLjN7.js";
5
- import { m as g } from "../mod-CSdCpRjf.js";
6
- import { r as l } from "../range-C-CjF-LI.js";
7
- function h(e) {
8
- return new u(e);
9
- }
10
- class k extends f {
11
- wpe;
12
- // Position embeddings
13
- constructor(n, t = "", o) {
14
- super(n, o), this.wpe = h({
15
- inputDim: this.config.blockSize,
16
- outputDim: this.config.nEmbed,
17
- name: t,
18
- embeddingsInitializer: b({ mean: 0, stddev: 0.02 })
19
- });
20
- }
21
- forward(n, t) {
22
- const o = n.cache?.[0]?.length ?? 0;
23
- return c(() => {
24
- const [, i] = t.shape, r = this.config.blockSize, m = l(0, i, 1, "int32"), a = g(p(m, s(o, "int32")), s(r, "int32")), d = this.wpe.apply(a);
25
- return t.add(d);
26
- });
27
- }
28
- }
29
- export {
30
- k as default
31
- };
@@ -1,12 +0,0 @@
1
- import { Tensor } from '@tensorflow/tfjs-core';
2
- import { default as BaseLayer, ForwardAttributes } from './BaseLayer';
3
- import { GPTConfig } from '../main';
4
- export interface RMSNormConfig {
5
- useGamma?: boolean;
6
- }
7
- export default class RMSNorm extends BaseLayer {
8
- private GAMMA;
9
- private rmsConfig;
10
- constructor(config: GPTConfig, rmsConfig: RMSNormConfig, name?: string, parent?: BaseLayer);
11
- forward(_: ForwardAttributes, x: Tensor): Tensor;
12
- }
@@ -1,22 +0,0 @@
1
- import { t as i } from "../index-CUXkjxiT.js";
2
- import e from "./BaseLayer.js";
3
- import { normRMS as m } from "../ops/normRMS.js";
4
- import { v as a } from "../variable-Ck482e3n.js";
5
- import { o as M } from "../ones-BytntneX.js";
6
- class l extends e {
7
- GAMMA;
8
- rmsConfig;
9
- constructor(r, t, s = "", o) {
10
- super(r, o), this.GAMMA = s, this.rmsConfig = t, (this.rmsConfig.useGamma ?? !0) && this.addVariable(this.GAMMA, a(M([r.nEmbed]), !0, this.GAMMA, "float32"));
11
- }
12
- forward(r, t) {
13
- return i(() => {
14
- this.startMemory();
15
- const s = m(t, this.rmsConfig.useGamma ?? !0 ? this.getVariable(this.GAMMA) : void 0);
16
- return this.endMemory("RMSNorm"), s;
17
- });
18
- }
19
- }
20
- export {
21
- l as default
22
- };
@@ -1,18 +0,0 @@
1
- import { Tensor } from '@tensorflow/tfjs-core';
2
- import { GPTConfig } from '../models/config';
3
- export default class RoPECache {
4
- private readonly config;
5
- readonly rotaryDim: number;
6
- private ropeBase;
7
- private ropeInvFreq;
8
- private ropeCos;
9
- private ropeSin;
10
- private ropeNegSin;
11
- private ropeCacheLen;
12
- constructor(config: GPTConfig);
13
- ensureRopeCache(needed: number): void;
14
- getCos(): Tensor | null;
15
- getSin(): Tensor | null;
16
- getNegSin(): Tensor | null;
17
- dispose(): void;
18
- }
@@ -1,50 +0,0 @@
1
- import { i as a, a as n, p as c, t as p, k as r } from "../index-CUXkjxiT.js";
2
- import { r as l } from "../zeros_like-CWjDdwr-.js";
3
- import { c as f, s as m } from "../unsorted_segment_sum-DJvk5xnh.js";
4
- import { r as h } from "../range-C-CjF-LI.js";
5
- class x {
6
- constructor(s) {
7
- this.config = s;
8
- const o = this.config.nEmbed / this.config.nHead;
9
- if (this.rotaryDim = o, this.rotaryDim % 2 !== 0)
10
- throw new Error("rotaryDim must be even");
11
- this.ropeBase = 1e4;
12
- const i = h(0, this.rotaryDim, 2, "float32"), e = a(i, n(this.rotaryDim, "float32")), t = c(n(this.ropeBase, "float32"), e);
13
- this.ropeInvFreq = l(t), e.dispose(), t.dispose(), i.dispose(), (this.config.modelType === "GenAI_NanoGPT_v1" ? this.config.useRope ?? !0 : !0) === !1 ? (this.ropeCos = null, this.ropeSin = null, this.ropeNegSin = null, this.ropeCacheLen = 0) : p(() => {
14
- this.ensureRopeCache(this.config.blockSize * 4);
15
- });
16
- }
17
- rotaryDim;
18
- ropeBase;
19
- ropeInvFreq;
20
- ropeCos = null;
21
- // [cacheLen, rotaryDim/2]
22
- ropeSin = null;
23
- // [cacheLen, rotaryDim/2]
24
- ropeNegSin = null;
25
- // [cacheLen, rotaryDim/2]
26
- ropeCacheLen = 0;
27
- ensureRopeCache(s) {
28
- p(() => {
29
- if (s <= this.ropeCacheLen) return;
30
- this.ropeCos && this.ropeCos.dispose(), this.ropeSin && this.ropeSin.dispose();
31
- const o = Math.max(s, this.ropeCacheLen + this.config.blockSize * 4), e = h(0, o, 1, "float32").expandDims(1).mul(this.ropeInvFreq.expandDims(0));
32
- this.ropeCos = r(f(e).expandDims(-1)), this.ropeSin = r(m(e).expandDims(-1)), this.ropeNegSin = r(this.ropeSin.neg()), this.ropeCacheLen = o;
33
- });
34
- }
35
- getCos() {
36
- return this.ropeCos;
37
- }
38
- getSin() {
39
- return this.ropeSin;
40
- }
41
- getNegSin() {
42
- return this.ropeNegSin;
43
- }
44
- dispose() {
45
- this.ropeCos && this.ropeCos.dispose(), this.ropeSin && this.ropeSin.dispose(), this.ropeInvFreq.dispose();
46
- }
47
- }
48
- export {
49
- x as default
50
- };
@@ -1,13 +0,0 @@
1
- import { Tensor } from '@tensorflow/tfjs-core';
2
- import { default as BaseLayer, ForwardAttributes } from './BaseLayer';
3
- import { GPTConfig } from '../models/config';
4
- export default class TiedEmbeddingOutputLayer extends BaseLayer {
5
- private vocabSize;
6
- private embedDim;
7
- private initializer;
8
- private WEIGHTS;
9
- constructor(config: GPTConfig, name: string, parent?: BaseLayer);
10
- embed(inputs: Tensor): Tensor;
11
- project(inputs: Tensor): Tensor;
12
- forward(_: ForwardAttributes, x: Tensor): Tensor;
13
- }
@@ -1,36 +0,0 @@
1
- import "../random_width-DN5ZtQkM.js";
2
- import "../index-CUXkjxiT.js";
3
- import { r as s } from "../exports_initializers-CYzKLjN7.js";
4
- import a from "./BaseLayer.js";
5
- import { dot16 as o } from "../ops/dot16.js";
6
- import { isPackedTensor as r } from "../utilities/packed.js";
7
- import { p as m } from "../pack16-bqltoUlR.js";
8
- import { transpose16 as d } from "../ops/transpose16.js";
9
- import { v as p } from "../variable-Ck482e3n.js";
10
- import { g as h } from "../gather-qIqEqaGn.js";
11
- class g extends a {
12
- vocabSize;
13
- embedDim;
14
- initializer;
15
- WEIGHTS;
16
- constructor(t, i, e) {
17
- super(t, e), this.WEIGHTS = i, this.vocabSize = t.vocabSize, this.embedDim = t.nEmbed, this.initializer = s({
18
- mean: 0,
19
- stddev: 0.02
20
- }), this.addVariable(this.WEIGHTS, p(this.initializer.apply([this.vocabSize, this.embedDim]), !0, i));
21
- }
22
- embed(t) {
23
- return h(this.getVariable(this.WEIGHTS), t, 0);
24
- }
25
- project(t) {
26
- const i = r(t) ? m(this.getVariable(this.WEIGHTS), void 0, 32) : this.getVariable(this.WEIGHTS), e = d(i);
27
- return r(t) && i.dispose(), o(t, e);
28
- }
29
- // Dummy, should not be used.
30
- forward(t, i) {
31
- return this.project(i);
32
- }
33
- }
34
- export {
35
- g as default
36
- };
@@ -1,27 +0,0 @@
1
- import { AttentionScores, CausalSelfAttentionConfig, KVCache } from './CausalSelfAttention';
2
- import { MLPConfig } from './MLP';
3
- import { RMSNormConfig } from './RMSNorm';
4
- import { default as BaseLayer, ForwardAttributes } from './BaseLayer';
5
- import { Tensor } from '@tensorflow/tfjs-core';
6
- import { GPTConfig } from '../models/config';
7
- interface BlockAttributes extends ForwardAttributes {
8
- pastKV?: KVCache;
9
- seed?: number;
10
- attentionScores?: AttentionScores;
11
- ropePositionOffset?: number;
12
- }
13
- export type TransformerBlockConfig = MLPConfig & RMSNormConfig & CausalSelfAttentionConfig;
14
- export default class Block extends BaseLayer<BlockAttributes> {
15
- private ln1;
16
- private attn;
17
- private ln2;
18
- private mlp;
19
- private index;
20
- skipped: boolean;
21
- private blockConfig;
22
- constructor(index: number, config: GPTConfig, blockConfig: TransformerBlockConfig, parent?: BaseLayer);
23
- private getMLPOutput;
24
- forward(attrs: BlockAttributes, x: Tensor): Tensor;
25
- dispose(): void;
26
- }
27
- export {};
@@ -1,40 +0,0 @@
1
- import p from "./CausalSelfAttention.js";
2
- import h from "./MLP.js";
3
- import l from "./RMSNorm.js";
4
- import m from "./BaseLayer.js";
5
- import { k as n, t as u } from "../index-CUXkjxiT.js";
6
- import { add16 as d } from "../ops/add16.js";
7
- class _ extends m {
8
- ln1;
9
- attn;
10
- ln2;
11
- mlp;
12
- index;
13
- skipped = !1;
14
- blockConfig;
15
- constructor(i, s, e, t) {
16
- super(s, t), this.index = i, this.blockConfig = e, this.ln1 = new l(s, this.blockConfig, `block_${this.index}_rms1`, this), this.attn = new p(this.index, s, this.blockConfig, this), this.ln2 = new l(s, this.blockConfig, `block_${this.index}_rms2`, this), this.mlp = new h(this.index, s, this.blockConfig, this);
17
- }
18
- getMLPOutput(i, s) {
19
- const e = this.ln2.call({ training: s.training }, i), t = this.mlp.call(s, e);
20
- s.outputEmbeddings ? (n(e), s.embeddings.push({ name: `block_ln2_${this.index}`, tensor: e })) : e.dispose();
21
- const o = d(i, t);
22
- return i.dispose(), s.outputEmbeddings ? (n(t), s.embeddings.push({ name: `block_mlp_out_${this.index}`, tensor: t })) : t.dispose(), o;
23
- }
24
- forward(i, s) {
25
- return u(() => {
26
- if (this.skipped)
27
- return s;
28
- const e = this.ln1.call(i, s), t = this.attn.call(i, e);
29
- i.outputEmbeddings ? (n(e), i.embeddings.push({ name: `block_ln1_${this.index}`, tensor: e })) : e.dispose();
30
- const o = d(s, t);
31
- return i.outputEmbeddings ? (n(t), i.embeddings.push({ name: `block_attn_out_${this.index}`, tensor: t })) : t.dispose(), this.getMLPOutput(o, i);
32
- });
33
- }
34
- dispose() {
35
- this.ln1.dispose(), this.attn.dispose(), this.ln2.dispose(), this.mlp.dispose();
36
- }
37
- }
38
- export {
39
- _ as default
40
- };
@@ -1,20 +0,0 @@
1
- import { Tensor, Variable } from '@tensorflow/tfjs-core';
2
- export default class WeightStore {
3
- private _variables;
4
- private touchedVariables;
5
- onWeightRead?: (name: string, variable: Variable) => Tensor;
6
- saveWeights(map: Map<string, Tensor[]>): void;
7
- loadWeights(weights: Map<string, Tensor[]>, reference: boolean, trainable?: boolean): void;
8
- addVariable(name: string, variable?: Variable): void;
9
- deleteVariable(name: string): void;
10
- get variables(): Variable[];
11
- get variableNames(): string[];
12
- get trainableVariables(): Variable[];
13
- getRawVariable(name: string): Variable;
14
- getVariable(name: string): Tensor;
15
- setTrainable(names: string[]): void;
16
- hasVariable(name: string): boolean;
17
- setVariable(name: string, variable: Variable): void;
18
- touchVariables(names: string[]): void;
19
- dispose(): void;
20
- }
@@ -1,76 +0,0 @@
1
- import { w as o } from "../index-CUXkjxiT.js";
2
- import { p as h } from "../index-DmeWGGmS.js";
3
- import { v as b } from "../variable-Ck482e3n.js";
4
- class d {
5
- _variables = /* @__PURE__ */ new Map();
6
- touchedVariables = /* @__PURE__ */ new Set();
7
- // Hooks
8
- onWeightRead;
9
- saveWeights(a) {
10
- this._variables.forEach((e, i) => {
11
- e && this.touchedVariables.has(i) && a.set(i, [o(e)]);
12
- });
13
- }
14
- loadWeights(a, e, i = !0) {
15
- a.forEach((s, r) => {
16
- const t = s[0], l = this._variables.get(r);
17
- l ? l.assign(t) : this._variables.set(r, b(t, i, r)), e ? this.touchedVariables.delete(r) : this.touchedVariables.add(r);
18
- });
19
- }
20
- addVariable(a, e) {
21
- this._variables.set(a, e || null);
22
- }
23
- deleteVariable(a) {
24
- const e = this._variables.get(a);
25
- e && e.dispose(), this._variables.delete(a), this.touchedVariables.delete(a);
26
- }
27
- get variables() {
28
- return Array.from(this._variables.values()).filter((e) => e !== null);
29
- }
30
- get variableNames() {
31
- return Array.from(this._variables.keys());
32
- }
33
- get trainableVariables() {
34
- return Array.from(this._variables.values()).filter(
35
- (e) => e !== null && e.trainable
36
- );
37
- }
38
- getRawVariable(a) {
39
- const e = this._variables.get(a);
40
- if (!e)
41
- throw new Error(`Variable ${a} not found`);
42
- return e;
43
- }
44
- getVariable(a) {
45
- const e = this._variables.get(a);
46
- if (!e)
47
- throw new Error(`Variable ${a} not found`);
48
- return this.onWeightRead ? this.onWeightRead(a, e) : e;
49
- }
50
- setTrainable(a) {
51
- const e = h(a);
52
- this._variables.forEach((i, s) => {
53
- i && (i.trainable = e(s));
54
- });
55
- }
56
- hasVariable(a) {
57
- return !!this._variables.get(a);
58
- }
59
- setVariable(a, e) {
60
- if (!this._variables.has(a))
61
- throw new Error(`Variable ${a} not found`);
62
- this._variables.set(a, e);
63
- }
64
- touchVariables(a) {
65
- for (const e of a)
66
- this._variables.get(e) && this.touchedVariables.add(e);
67
- }
68
- dispose() {
69
- this._variables.forEach((a) => {
70
- a?.dispose();
71
- }), this._variables.clear();
72
- }
73
- }
74
- export {
75
- d as default
76
- };
@@ -1,6 +0,0 @@
1
- import { LoadResult } from './types';
2
- export declare const VERSION = 2;
3
- export interface LoadModelOptions {
4
- sourceURL?: string;
5
- }
6
- export declare function loadModel(data: Blob | Buffer | string, options?: LoadModelOptions): Promise<LoadResult>;
@@ -1,68 +0,0 @@
1
- import { z as i } from "../jszip.min-BZhlzntC.js";
2
- import u from "./oldZipLoad.js";
3
- import d from "./newZipLoad.js";
4
- import w from "./loadHF.js";
5
- import { loadZipMeta as s } from "./loadZipMeta.js";
6
- import { load_safetensors as g } from "../utilities/safetensors.js";
7
- const j = 2;
8
- async function h(e) {
9
- const t = await fetch(e);
10
- if (!t.ok)
11
- throw new Error(`Failed to fetch ${e}: ${t.statusText}`);
12
- return t.arrayBuffer();
13
- }
14
- async function p(e, t, o) {
15
- const a = e.file("model.safetensors");
16
- if (!a)
17
- return;
18
- const r = await a.async("arraybuffer"), c = await g(r), n = /* @__PURE__ */ new Map();
19
- for (const [l, m] of Object.entries(c))
20
- n.set(l, [m]);
21
- t.weightStore.loadWeights(n, o);
22
- }
23
- async function y(e, t) {
24
- const o = e.file("config.json");
25
- if (!o)
26
- return;
27
- const a = await o.async("string"), r = JSON.parse(a);
28
- if (r.loraName) {
29
- if (t.hasLoRA())
30
- throw new Error("Model already has LoRA attached");
31
- t.attachLoRA(r.loraName);
32
- }
33
- }
34
- async function f(e, t) {
35
- if (t.reference) {
36
- const o = await L(t.reference);
37
- return await p(e, o.model, !!t.url), await y(e, o.model), o.model.config.loraName && o.model.attachLoRA(o.model.config.loraName), {
38
- ...o,
39
- metaData: {
40
- ...o.metaData,
41
- ...t
42
- }
43
- };
44
- } else {
45
- if (e.file("manifest.json"))
46
- return u(e, t);
47
- {
48
- const o = await d(e, t);
49
- return o.model.config.loraName && o.model.attachLoRA(o.model.config.loraName), o;
50
- }
51
- }
52
- }
53
- async function L(e, t) {
54
- if (typeof e == "string")
55
- if (e.startsWith("http://") || e.startsWith("https://")) {
56
- const o = await h(e), a = await i.loadAsync(o), r = await s(a);
57
- return r.url = e, f(a, r);
58
- } else
59
- return w(e);
60
- else {
61
- const o = await i.loadAsync(e), a = await s(o);
62
- return a.url = t?.sourceURL || void 0, f(o, a);
63
- }
64
- }
65
- export {
66
- j as VERSION,
67
- L as loadModel
68
- };
@@ -1,8 +0,0 @@
1
- import { ITokeniser } from '../main';
2
- import { default as Model, ModelForwardAttributes } from '../models/model';
3
- import { TransformersMetadata } from './types';
4
- export default function loadHuggingFace(name: string): Promise<{
5
- model: Model<ModelForwardAttributes>;
6
- tokeniser: ITokeniser;
7
- metaData: TransformersMetadata;
8
- }>;
@@ -1,22 +0,0 @@
1
- import w from "./loadTransformers.js";
2
- async function u(t) {
3
- const r = `https://huggingface.co/${t}/resolve/main/config.json`, a = `https://huggingface.co/${t}/resolve/main/tokeniser.json`, i = `https://huggingface.co/${t}/resolve/main/meta.json`, c = `https://huggingface.co/${t}/resolve/main/model.safetensors`, [o, e, s, n] = await Promise.all([
4
- fetch(r),
5
- fetch(a),
6
- fetch(i),
7
- fetch(c)
8
- ]);
9
- if (!o.ok)
10
- throw new Error(`Failed to fetch config from ${r}: ${o.statusText}`);
11
- if (!e.ok)
12
- throw new Error(`Failed to fetch tokeniser from ${a}: ${e.statusText}`);
13
- if (!s.ok)
14
- throw new Error(`Failed to fetch meta from ${i}: ${s.statusText}`);
15
- if (!n.ok)
16
- throw new Error(`Failed to fetch weights from ${c}: ${n.statusText}`);
17
- const f = await o.json(), g = await e.json(), h = await s.json(), l = await n.arrayBuffer();
18
- return w(f, g, h, l);
19
- }
20
- export {
21
- u as default
22
- };
@@ -1,4 +0,0 @@
1
- import { GPTConfig } from '../models/config';
2
- import { LoadResult, TransformersConfig, TransformersMetadata, TransformersTokeniser } from './types';
3
- export declare function mapTransformersConfigToGPTConfig(config: TransformersConfig): GPTConfig;
4
- export default function loadTransformers(config: TransformersConfig, tokeniser: TransformersTokeniser, metadata: TransformersMetadata, weightData: ArrayBuffer): Promise<LoadResult>;
@@ -1,44 +0,0 @@
1
- import p from "../tokeniser/CharTokeniser.js";
2
- import _ from "../tokeniser/bpe.js";
3
- import { load_safetensors as b } from "../utilities/safetensors.js";
4
- import { aa as c } from "../index-CUXkjxiT.js";
5
- import { dummyPassAsync as u } from "../utilities/dummy.js";
6
- import y from "../models/factory.js";
7
- function h(e) {
8
- let a;
9
- return e.model_type === "GenAI_NanoGPT_v1" ? a = {
10
- modelType: "GenAI_NanoGPT_v1",
11
- vocabSize: e.vocab_size,
12
- blockSize: e.block_size,
13
- nLayer: e.num_hidden_layers,
14
- nHead: e.num_attention_heads,
15
- nEmbed: e.hidden_size,
16
- mlpFactor: e.mlpFactor,
17
- useRope: e.useRope
18
- } : a = {
19
- modelType: "GenAI_NanoGPT_v2",
20
- vocabSize: e.vocab_size,
21
- blockSize: e.block_size,
22
- nLayer: e.num_hidden_layers,
23
- nHead: e.num_attention_heads,
24
- nEmbed: e.hidden_size,
25
- mlpFactor: e.mlpFactor,
26
- loraConfig: e.loraConfig ? new Map(Object.entries(e.loraConfig)) : void 0,
27
- loraName: e.loraName,
28
- windowSize: e.windowSize
29
- }, a;
30
- }
31
- async function G(e, a, r, n) {
32
- const m = h(e), o = (a.type ?? "char") === "char" ? new p(a.vocab) : new _(a.vocab, a.merges);
33
- a.datasetID && (o.datasetID = a.datasetID), a.id ? o.id = a.id : o.generateID();
34
- const d = await b(n), s = /* @__PURE__ */ new Map();
35
- for (const [i, l] of Object.entries(d))
36
- s.set(i, [l]);
37
- c();
38
- const t = y(m);
39
- return t.metaData = r, await u(t), t.weightStore.loadWeights(s, !!r.url), { model: t, tokeniser: o, metaData: r };
40
- }
41
- export {
42
- G as default,
43
- h as mapTransformersConfigToGPTConfig
44
- };
@@ -1,3 +0,0 @@
1
- import { default as zip } from 'jszip';
2
- import { TransformersMetadata } from './types';
3
- export declare function loadZipMeta(zipFile: zip): Promise<TransformersMetadata>;
@@ -1,16 +0,0 @@
1
- async function r(t) {
2
- const e = await t.file("meta.json")?.async("string");
3
- let a = { version: 0, application: "" };
4
- if (e)
5
- try {
6
- a = JSON.parse(e);
7
- } catch (n) {
8
- throw console.error(n), new Error("Failed to parse meta.json in the zip archive");
9
- }
10
- else
11
- console.warn("meta.json not found in the zip archive, using default metadata");
12
- return a;
13
- }
14
- export {
15
- r as loadZipMeta
16
- };
@@ -1,3 +0,0 @@
1
- import { default as zip } from 'jszip';
2
- import { LoadResult, TransformersMetadata } from './types';
3
- export default function loadZipFile(zipFile: zip, metaData: TransformersMetadata): Promise<LoadResult>;
@@ -1,31 +0,0 @@
1
- import h from "./loadTransformers.js";
2
- import { AdamWOptimizer as m } from "../training/AdamW.js";
3
- async function u(i, c) {
4
- const t = await i.file("config.json")?.async("string");
5
- if (!t)
6
- throw new Error("Config file not found in the zip archive");
7
- const g = JSON.parse(t), n = await i.file("tokeniser.json")?.async("string");
8
- if (!n)
9
- throw new Error("Tokeniser file not found in the zip archive");
10
- const w = JSON.parse(n), e = await i.file("model.safetensors")?.async("arraybuffer");
11
- if (!e)
12
- throw new Error("Model weights not found in the zip archive");
13
- const r = await i.file("optimizer_config.json")?.async("string");
14
- let o;
15
- if (r) {
16
- const l = JSON.parse(r), f = await i.file("optimizer.safetensors")?.async("arraybuffer");
17
- if (!f)
18
- throw new Error("Optimizer weights not found in the zip archive");
19
- o = new m(l), await o.loadMoments(f);
20
- }
21
- const a = await i.file("training_log.json")?.async("string");
22
- let s;
23
- return a && (s = JSON.parse(a)), {
24
- ...await h(g, w, c, e),
25
- optimizer: o,
26
- log: s
27
- };
28
- }
29
- export {
30
- u as default
31
- };
@@ -1,9 +0,0 @@
1
- import { default as zip } from 'jszip';
2
- import { ITokeniser } from '../main';
3
- import { default as Model, ModelForwardAttributes } from '../models/model';
4
- import { TransformersMetadata } from './types';
5
- export default function loadOldModel(zipFile: zip, metaData: TransformersMetadata): Promise<{
6
- model: Model<ModelForwardAttributes>;
7
- tokeniser: ITokeniser;
8
- metaData: TransformersMetadata;
9
- }>;