@genai-fi/nanogpt 1.5.0 → 1.6.1

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 (319) hide show
  1. package/dist/{DatasetBuilder-DU1G1OKX.js → DatasetBuilder-DRDW8tcM.js} +85 -86
  2. package/dist/Generator-8IK28IWR.js +316 -0
  3. package/dist/{RealDiv-CSnvtN2E.js → RealDiv-Cl8k3YTx.js} +54 -62
  4. package/dist/{Reshape-BlylqwWy.js → Reshape-CKxKPKqi.js} +9 -12
  5. package/dist/Reshape-H5zZRgr9.js +16 -0
  6. package/dist/RoPECache-dYscFINl.js +722 -0
  7. package/dist/TeachableLLM.js +29 -34
  8. package/dist/api/beamer.js +5 -6
  9. package/dist/api/responses.js +11 -12
  10. package/dist/api/training.js +12 -14
  11. package/dist/axis_util-rF9RnwKE.js +37 -0
  12. package/dist/backend.js +5 -6
  13. package/dist/{backend_util-DAV0I34P.js → backend_util-Cpp0Gwlp.js} +180 -185
  14. package/dist/{binary_op_util-CrYk9LXL.js → binary_op_util-WY9YIl0q.js} +3 -7
  15. package/dist/broadcast_to-CGvLNiQ0.js +20 -0
  16. package/dist/checks/appendCache.js +7 -7
  17. package/dist/checks/attentionMask.js +9 -8
  18. package/dist/checks/check.js +1 -2
  19. package/dist/checks/gelu.js +6 -6
  20. package/dist/checks/index.js +24 -25
  21. package/dist/checks/matMulGelu.js +7 -7
  22. package/dist/checks/normRMS.js +14 -12
  23. package/dist/checks/normRMSGrad.js +9 -8
  24. package/dist/checks/packUnpack.js +7 -7
  25. package/dist/checks/qkv.js +1 -34
  26. package/dist/checks/rope.js +6 -6
  27. package/dist/checks/weights.js +1 -2
  28. package/dist/clip_by_value-D-UX9am5.js +13 -0
  29. package/dist/complex-Cl904TqN.js +13 -0
  30. package/dist/{complex_util-CkazZsaH.js → complex_util-BBlPAm-s.js} +1 -2
  31. package/dist/concat-Oip5acVY.js +14 -0
  32. package/dist/{concat_util-CWzvQQlK.js → concat_util-CY45Hf4F.js} +2 -3
  33. package/dist/data/docx.js +3 -4
  34. package/dist/data/pdf.js +11 -14
  35. package/dist/data/stream.js +1 -2
  36. package/dist/data/textLoader.js +16 -15
  37. package/dist/data-CV_i_H6B.js +11 -0
  38. package/dist/data.js +5 -12
  39. package/dist/dist-CMMLi-qO.js +2675 -0
  40. package/dist/{dist-BGVm64AY.js → dist-DeVH1nGn.js} +1465 -1573
  41. package/dist/{dist-CwK5S7Ls.js → dist-DyL7qSLJ.js} +2664 -2400
  42. package/dist/dropout16-CA31Ud5a.js +20 -0
  43. package/dist/dropout_util-SiFMbFXz.js +22 -0
  44. package/dist/{eventemitter3-D_qV3Lof.js → eventemitter3-wmfmOP_f.js} +2 -3
  45. package/dist/expand_dims-Dh3Fulyn.js +10 -0
  46. package/dist/floor-BwjmUb7X.js +8 -0
  47. package/dist/gather-B5Z1RFt5.js +14 -0
  48. package/dist/gatherSub-CRUfUzBa.js +22 -0
  49. package/dist/gelu-Xx9-ohH9.js +25 -0
  50. package/dist/{gpgpu_math-20tPK8LM.js → gpgpu_math-48m8q3jI.js} +265 -286
  51. package/dist/inference/Beamer.js +34 -27
  52. package/dist/inference/Generator.js +1 -273
  53. package/dist/inference/tokenisePrompt.js +5 -4
  54. package/dist/inference/types.d.ts +6 -0
  55. package/dist/inference/utilities.js +1 -2
  56. package/dist/{jszip.min-DKa1Rjyn.js → jszip.min-Btv48m44.js} +68 -64
  57. package/dist/{kernel_funcs_utils-ql8Y8qPn.js → kernel_funcs_utils-BYRpSfV_.js} +39 -42
  58. package/dist/layers/BaseLayer.js +9 -10
  59. package/dist/layers/GQA.js +45 -44
  60. package/dist/layers/HeadLayer.js +13 -13
  61. package/dist/layers/LoRA.js +17 -20
  62. package/dist/layers/MHA.d.ts +2 -2
  63. package/dist/layers/MHA.js +46 -45
  64. package/dist/layers/MLP.js +22 -21
  65. package/dist/layers/PositionEmbedding.js +14 -13
  66. package/dist/layers/RMSNorm.js +14 -13
  67. package/dist/layers/RoPECache.js +1 -338
  68. package/dist/layers/TiedEmbedding.js +15 -14
  69. package/dist/layers/TransformerBlock.d.ts +3 -9
  70. package/dist/layers/TransformerBlock.js +29 -30
  71. package/dist/layers/WeightStore.js +4 -5
  72. package/dist/layers-CFqEip3s.js +13 -0
  73. package/dist/layers.js +3 -11
  74. package/dist/loader/load.js +27 -24
  75. package/dist/loader/loadHF.js +3 -3
  76. package/dist/loader/loadTransformers.js +5 -6
  77. package/dist/loader/loadZipMeta.js +1 -2
  78. package/dist/loader/newZipLoad.js +1 -2
  79. package/dist/loader/oldZipLoad.js +8 -9
  80. package/dist/loader/save.js +15 -16
  81. package/dist/main.js +3281 -3463
  82. package/dist/{matMul16-CO1QhsRt.js → matMul16-tE26fnhf.js} +29 -27
  83. package/dist/{matMulGelu-CBoqTZM7.js → matMulGelu-ASUWlKqu.js} +33 -33
  84. package/dist/mat_mul-R9_DWmIT.js +16 -0
  85. package/dist/models/Llama.js +48 -49
  86. package/dist/models/NanoGPTV1.js +53 -54
  87. package/dist/models/NanoGPTV2.js +48 -49
  88. package/dist/models/Qwen3.js +48 -49
  89. package/dist/models/config.js +3 -8
  90. package/dist/models/factory.js +7 -8
  91. package/dist/models/model.d.ts +5 -7
  92. package/dist/models/model.js +1 -2
  93. package/dist/models-DyBpJJwM.js +13 -0
  94. package/dist/models.js +6 -14
  95. package/dist/mul16-C7sqgqik.js +41 -0
  96. package/dist/non_max_suppression_impl-B0H318rb.js +72 -0
  97. package/dist/not_equal-Bu3O8rh_.js +67 -0
  98. package/dist/one_hot-TEMPumJj.js +14 -0
  99. package/dist/ones-DpPXWa6A.js +13 -0
  100. package/dist/ops/adamAdjust.js +2 -3
  101. package/dist/ops/adamMoments.js +2 -3
  102. package/dist/ops/add16.js +2 -3
  103. package/dist/ops/appendCache.js +9 -8
  104. package/dist/ops/attentionMask.d.ts +1 -1
  105. package/dist/ops/attentionMask.js +8 -5
  106. package/dist/ops/concat16.js +5 -5
  107. package/dist/ops/cpu/adamAdjust.js +7 -8
  108. package/dist/ops/cpu/adamMoments.js +5 -5
  109. package/dist/ops/cpu/appendCache.js +3 -3
  110. package/dist/ops/cpu/attentionMask.js +12 -8
  111. package/dist/ops/cpu/fusedSoftmax.js +3 -3
  112. package/dist/ops/cpu/gatherSub.js +1 -12
  113. package/dist/ops/cpu/gelu.js +12 -13
  114. package/dist/ops/cpu/matMul16.js +7 -7
  115. package/dist/ops/cpu/matMulGelu.js +21 -18
  116. package/dist/ops/cpu/matMulMul.js +8 -9
  117. package/dist/ops/cpu/mulDropout.js +8 -9
  118. package/dist/ops/cpu/normRMS.js +12 -13
  119. package/dist/ops/cpu/qkv.js +14 -13
  120. package/dist/ops/cpu/rope.js +11 -8
  121. package/dist/ops/cpu/scatterSub.js +1 -12
  122. package/dist/ops/dot16.js +16 -17
  123. package/dist/ops/dropout.js +9 -8
  124. package/dist/ops/dropout16.js +1 -22
  125. package/dist/ops/gatherSub.js +3 -4
  126. package/dist/ops/gelu.js +1 -2
  127. package/dist/ops/globalNorm.js +10 -10
  128. package/dist/ops/grads/add16.js +16 -17
  129. package/dist/ops/grads/attentionMask.js +6 -7
  130. package/dist/ops/grads/dropout16.js +1 -1
  131. package/dist/ops/grads/gelu.js +1 -2
  132. package/dist/ops/grads/matMul16.js +1 -2
  133. package/dist/ops/grads/matMulGelu.js +6 -7
  134. package/dist/ops/grads/mul16.js +1 -1
  135. package/dist/ops/grads/normRMS.js +8 -9
  136. package/dist/ops/grads/pack16.js +1 -2
  137. package/dist/ops/grads/qkv.js +10 -10
  138. package/dist/ops/grads/rope.js +1 -2
  139. package/dist/ops/grads/silu.js +1 -2
  140. package/dist/ops/grads/softmax16.js +6 -7
  141. package/dist/ops/grads/unpack16.js +1 -2
  142. package/dist/ops/grads/utils.js +1 -2
  143. package/dist/ops/matMul16.d.ts +1 -1
  144. package/dist/ops/matMul16.js +1 -2
  145. package/dist/ops/matMulGelu.js +3 -4
  146. package/dist/ops/matMulMul.js +2 -3
  147. package/dist/ops/mul16.js +1 -43
  148. package/dist/ops/mulDrop.js +2 -3
  149. package/dist/ops/normRMS.js +2 -3
  150. package/dist/ops/pack16.js +1 -2
  151. package/dist/ops/qkv.js +2 -3
  152. package/dist/ops/reshape16.js +11 -11
  153. package/dist/ops/rope.js +1 -2
  154. package/dist/ops/scatterSub.js +3 -4
  155. package/dist/ops/silu.js +1 -2
  156. package/dist/ops/slice16.js +5 -5
  157. package/dist/ops/softmax16.js +3 -4
  158. package/dist/ops/sub16.js +3 -4
  159. package/dist/ops/sum16.js +3 -3
  160. package/dist/ops/transpose16.js +16 -15
  161. package/dist/ops/unpack16.js +1 -2
  162. package/dist/ops/webgl/adamAdjust.js +8 -9
  163. package/dist/ops/webgl/adamMoments.js +2 -3
  164. package/dist/ops/webgl/appendCache.js +2 -3
  165. package/dist/ops/webgl/attentionMask.js +2 -3
  166. package/dist/ops/webgl/dropout16.js +2 -3
  167. package/dist/ops/webgl/fusedSoftmax.js +13 -13
  168. package/dist/ops/webgl/gatherSub.js +2 -3
  169. package/dist/ops/webgl/gelu.js +11 -12
  170. package/dist/ops/webgl/log.js +10 -10
  171. package/dist/ops/webgl/matMul16.js +31 -24
  172. package/dist/ops/webgl/matMulGelu.js +1 -2
  173. package/dist/ops/webgl/matMulMul.js +3 -4
  174. package/dist/ops/webgl/mulDropout.js +2 -3
  175. package/dist/ops/webgl/normRMS.js +11 -10
  176. package/dist/ops/webgl/qkv.js +2 -3
  177. package/dist/ops/webgl/rope.js +4 -5
  178. package/dist/ops/webgl/scatterSub.js +2 -3
  179. package/dist/ops/webgpu/adamAdjust.js +13 -14
  180. package/dist/ops/webgpu/adamMoments.js +13 -14
  181. package/dist/ops/webgpu/add16.js +3 -4
  182. package/dist/ops/webgpu/appendCache.js +20 -21
  183. package/dist/ops/webgpu/attentionMask.js +18 -19
  184. package/dist/ops/webgpu/attentionMask32_program.js +7 -8
  185. package/dist/ops/webgpu/clipScale.js +11 -12
  186. package/dist/ops/webgpu/concat16.js +17 -18
  187. package/dist/ops/webgpu/dropout16.js +6 -7
  188. package/dist/ops/webgpu/gatherSub.js +11 -12
  189. package/dist/ops/webgpu/gelu.js +10 -11
  190. package/dist/ops/webgpu/index.js +17 -17
  191. package/dist/ops/webgpu/matMul16.js +74 -63
  192. package/dist/ops/webgpu/matMul16_program.d.ts +2 -1
  193. package/dist/ops/webgpu/matMul16_program.js +29 -21
  194. package/dist/ops/webgpu/mul16.js +3 -4
  195. package/dist/ops/webgpu/norm2.js +9 -10
  196. package/dist/ops/webgpu/normRMS.js +9 -10
  197. package/dist/ops/webgpu/normRMS16_program.js +1 -2
  198. package/dist/ops/webgpu/normRMS32_program.js +1 -2
  199. package/dist/ops/webgpu/normRMSGrad.js +30 -30
  200. package/dist/ops/webgpu/pack16.js +2 -3
  201. package/dist/ops/webgpu/pack16_program.js +3 -4
  202. package/dist/ops/webgpu/qkv.js +10 -11
  203. package/dist/ops/webgpu/rope.js +26 -27
  204. package/dist/ops/webgpu/scatterSub.js +12 -13
  205. package/dist/ops/webgpu/silu.js +10 -11
  206. package/dist/ops/webgpu/slice16.js +17 -18
  207. package/dist/ops/webgpu/softmax16.js +9 -9
  208. package/dist/ops/webgpu/softmax16_program.js +9 -10
  209. package/dist/ops/webgpu/softmax16_subgroup_program.js +11 -12
  210. package/dist/ops/webgpu/softmax16grad.js +8 -9
  211. package/dist/ops/webgpu/sub16.js +3 -4
  212. package/dist/ops/webgpu/sum16.js +16 -15
  213. package/dist/ops/webgpu/transpose16.js +13 -12
  214. package/dist/ops/webgpu/transpose16_program.js +3 -4
  215. package/dist/ops/webgpu/transpose16_shared_program.js +17 -18
  216. package/dist/ops/webgpu/unpack16.js +8 -9
  217. package/dist/ops/webgpu/utils/binary_op.js +20 -21
  218. package/dist/ops/webgpu/utils/deviceInfo.js +1 -2
  219. package/dist/ops/webgpu/utils/reductions.js +21 -20
  220. package/dist/ops-Be5ACU5R.js +13 -0
  221. package/dist/ops-C1UpdEYM.js +509 -0
  222. package/dist/{pack16-BhuXNUS7.js → pack16-BHO4t1-M.js} +14 -17
  223. package/dist/pad-Dy-1IP3A.js +13 -0
  224. package/dist/patches/webgpu_backend.js +18 -19
  225. package/dist/patches/webgpu_base.js +2 -3
  226. package/dist/patches/webgpu_program.js +21 -22
  227. package/dist/{pdf-Bzuk68Vy.js → pdf-CbnQ75VG.js} +380 -701
  228. package/dist/{picomatch-BO4HbNfo.js → picomatch--TW6gyBJ.js} +229 -291
  229. package/dist/qkv-BQfNPucX.js +42 -0
  230. package/dist/rand_util-_vCY93Uw.js +44 -0
  231. package/dist/random_normal-DUIT8kyC.js +11 -0
  232. package/dist/range-CYvQC3fW.js +13 -0
  233. package/dist/relu-C4XULT8A.js +8 -0
  234. package/dist/reshape-DJb1jgMt.js +8 -0
  235. package/dist/resize_nearest_neighbor-DAqcTYUe.js +188 -0
  236. package/dist/{chunk-CWhphoD1.js → rolldown-runtime-CwxnZyOB.js} +4 -5
  237. package/dist/{rope-BPu_uooz.js → rope-JjBVufF_.js} +6 -8
  238. package/dist/scatterSub-BOnqk-uY.js +27 -0
  239. package/dist/scatter_nd_util-BepMCpLY.js +34 -0
  240. package/dist/seedrandom-SHEGFK6H.js +282 -0
  241. package/dist/selu_util-DeOTf-sc.js +27 -0
  242. package/dist/shared-BIDMUBCs.js +1864 -0
  243. package/dist/{shared-CfTzpULd.js → shared-CX_iPI5K.js} +2 -3
  244. package/dist/silu-DsAE2cJ5.js +23 -0
  245. package/dist/slice-Dlb1FlzG.js +13 -0
  246. package/dist/{slice_util-Dve4TkDn.js → slice_util-BVgPRoij.js} +3 -4
  247. package/dist/softmax-Dpav_dWw.js +10 -0
  248. package/dist/split-DYnT8chz.js +11 -0
  249. package/dist/squeeze-B3XYGAlg.js +9 -0
  250. package/dist/stack-Dbbt9mIk.js +10 -0
  251. package/dist/step-DA-5DNu9.js +348 -0
  252. package/dist/{stream-BpAwcvHz.js → stream-BBe2apn4.js} +68 -88
  253. package/dist/sum-C8qNbFNp.js +13 -0
  254. package/dist/tensor-ALxWZfmz.js +7 -0
  255. package/dist/tensor1d-BHgkkhTE.js +9 -0
  256. package/dist/tensor2d-ARItvqVn.js +10 -0
  257. package/dist/tensor4d-D1zRBipJ.js +10 -0
  258. package/dist/tfjs_backend-CsXOum0h.js +685 -0
  259. package/dist/tile-DfyQ0KX-.js +10 -0
  260. package/dist/tokenise-DbS2Ea-T.js +14 -0
  261. package/dist/tokenise.js +6 -15
  262. package/dist/tokeniser/BaseTokeniser.js +5 -9
  263. package/dist/tokeniser/CharTokeniser.js +1 -2
  264. package/dist/tokeniser/bpe.js +19 -20
  265. package/dist/topk-BrU2pkrR.js +19 -0
  266. package/dist/training/AdamW.js +35 -31
  267. package/dist/training/BasicTrainer.js +56 -56
  268. package/dist/training/DatasetBuilder.js +1 -2
  269. package/dist/training/Evaluator.js +4 -4
  270. package/dist/training/LRScheduler.js +1 -2
  271. package/dist/training/PreTrainer.js +7 -8
  272. package/dist/training/SFTTrainer.js +7 -8
  273. package/dist/training/configure.js +16 -15
  274. package/dist/training/factory.js +1 -2
  275. package/dist/training/loss.js +1 -2
  276. package/dist/training/orthoGrad.js +2 -3
  277. package/dist/training/prepareData.js +18 -17
  278. package/dist/training/sparseCrossEntropy.js +38 -32
  279. package/dist/training/tasks/TokenStore.js +21 -22
  280. package/dist/training/tasks/tokenStream.js +1 -2
  281. package/dist/training/validateOptions.js +1 -2
  282. package/dist/training/validation.js +1 -2
  283. package/dist/transpose-BC-M_OoT.js +34 -0
  284. package/dist/unsorted_segment_sum-BelC7R-q.js +408 -0
  285. package/dist/utilities/arrayClose.js +5 -4
  286. package/dist/utilities/arrayShape.js +1 -2
  287. package/dist/utilities/datasetID.js +1 -2
  288. package/dist/utilities/dummy.js +15 -15
  289. package/dist/utilities/float16.js +10 -10
  290. package/dist/utilities/maxHeap.js +1 -2
  291. package/dist/utilities/multinomialCPU.d.ts +1 -2
  292. package/dist/utilities/multinomialCPU.js +6 -8
  293. package/dist/utilities/packed.js +2 -3
  294. package/dist/utilities/parameters.js +3 -4
  295. package/dist/utilities/performance.js +2 -3
  296. package/dist/utilities/profile.js +3 -4
  297. package/dist/utilities/random.js +1 -2
  298. package/dist/utilities/safetensors.js +14 -14
  299. package/dist/utilities/sentences.js +16 -13
  300. package/dist/utilities/tokenParse.js +1 -2
  301. package/dist/utilities/tokens.js +5 -6
  302. package/dist/utilities/topP.d.ts +1 -0
  303. package/dist/utilities/topP.js +20 -13
  304. package/dist/utilities/waitForModel.js +1 -2
  305. package/dist/utilities/weights.js +4 -4
  306. package/dist/utilities/yielder.js +1 -2
  307. package/dist/{v4-BK7K-jy_.js → v4-YCkfo8OR.js} +4 -7
  308. package/dist/{webgpu-IAn9VotJ.js → webgpu-BHX-uBym.js} +156 -163
  309. package/dist/{webgpu_program-B0PokuRJ.js → webgpu_program-DvkFqRlR.js} +28 -29
  310. package/dist/{webgpu_util-DfODg6XI.js → webgpu_util-5QTyovaf.js} +2 -3
  311. package/dist/zeros-hxKGkRfl.js +12 -0
  312. package/package.json +3 -3
  313. package/dist/Reshape-CwxdaU8n.js +0 -17
  314. package/dist/dist-Da20xy8E.js +0 -6375
  315. package/dist/gelu-B6637MKa.js +0 -27
  316. package/dist/selu_util-B_AFEfoz.js +0 -24
  317. package/dist/shared-24EoeHJl.js +0 -1314
  318. package/dist/silu-B6bvCgJ7.js +0 -25
  319. package/dist/tfjs_backend-h5weiy1O.js +0 -614
@@ -1,338 +1 @@
1
- import { $n as e, $t as t, A as n, An as r, At as i, B as a, Bn as o, Br as s, Bt as ee, D as te, Dt as c, E as ne, Ei as l, Et as re, Fn as ie, Fr as ae, Ft as oe, G as se, Gn as ce, Gr as u, H as le, Hr as ue, Ht as de, Ir as d, It as f, J as p, Jt as m, K as h, Kn as g, Kr as _, Lr as v, Lt as y, Mn as b, Mr as x, Nn as S, Nr as C, Nt as w, O as T, Pn as E, Pr as D, Ps as O, Pt as k, Qn as A, Qt as j, R as M, Rr as N, Rt as P, St as F, Tt as I, U as L, Un as R, Ur as z, Ut as B, V, Vn as H, Vr as fe, Vt as pe, W as me, Wn as he, Wr as ge, Xn as _e, Xt as ve, Y as ye, Yr as U, Yt as be, Zt as xe, _n as W, _r as Se, _t as Ce, an as we, at as Te, bn as Ee, br as G, bt as De, cn as Oe, ct as ke, di as K, dn as Ae, dr as q, dt as J, en as je, et as Me, fn as Ne, fr as Pe, g as Fe, gn as Ie, gr as Le, gt as Re, h as ze, hn as Be, hr as Ve, ht as He, in as Ue, ir as We, it as Ge, jn as Ke, jt as qe, kn as Je, ln as Ye, lt as Xe, mn as Ze, mr as Qe, nn as $e, nt as et, oi as Y, on as tt, or as nt, ot as rt, pn as it, pr as at, q as ot, qr as st, rn as ct, rt as lt, sr as ut, st as dt, tn as ft, tt as X, un as pt, ut as Z, vn as Q, vt as mt, w as ht, wi as $, xt as gt, yn as _t, yr as vt, yt, z as bt, zn as xt, zr as St, zt as Ct } from "../dist-Da20xy8E.js";
2
- //#endregion
3
- //#region node_modules/@tensorflow/tfjs-core/dist/public/chained_ops/zeros_like.js
4
- l().prototype.abs = function() {
5
- return this.throwIfDisposed(), z(this);
6
- }, l().prototype.acos = function() {
7
- return this.throwIfDisposed(), ue(this);
8
- }, l().prototype.acosh = function() {
9
- return this.throwIfDisposed(), fe(this);
10
- }, l().prototype.add = function(e) {
11
- return this.throwIfDisposed(), st(this, e);
12
- }, l().prototype.all = function(e, t) {
13
- return this.throwIfDisposed(), s(this, e, t);
14
- }, l().prototype.any = function(e, t) {
15
- return this.throwIfDisposed(), St(this, e, t);
16
- }, l().prototype.argMax = function(e) {
17
- return this.throwIfDisposed(), N(this, e);
18
- }, l().prototype.argMin = function(e) {
19
- return this.throwIfDisposed(), v(this, e);
20
- }, l().prototype.asScalar = function() {
21
- return this.throwIfDisposed(), O(this.size === 1, () => "The array must have only 1 element."), G(this, []);
22
- }, l().prototype.asType = function(e) {
23
- return this.throwIfDisposed(), U(this, e);
24
- }, l().prototype.as1D = function() {
25
- return this.throwIfDisposed(), G(this, [this.size]);
26
- }, l().prototype.as2D = function(e, t) {
27
- return this.throwIfDisposed(), G(this, [e, t]);
28
- }, l().prototype.as3D = function(e, t, n) {
29
- return this.throwIfDisposed(), G(this, [
30
- e,
31
- t,
32
- n
33
- ]);
34
- }, l().prototype.as4D = function(e, t, n, r) {
35
- return this.throwIfDisposed(), G(this, [
36
- e,
37
- t,
38
- n,
39
- r
40
- ]);
41
- }, l().prototype.as5D = function(e, t, n, r, i) {
42
- return this.throwIfDisposed(), G(this, [
43
- e,
44
- t,
45
- n,
46
- r,
47
- i
48
- ]);
49
- }, l().prototype.asin = function() {
50
- return this.throwIfDisposed(), d(this);
51
- }, l().prototype.asinh = function() {
52
- return this.throwIfDisposed(), ae(this);
53
- }, l().prototype.atan = function() {
54
- return this.throwIfDisposed(), D(this);
55
- }, l().prototype.atan2 = function(e) {
56
- return this.throwIfDisposed(), C(this, e);
57
- }, l().prototype.atanh = function() {
58
- return this.throwIfDisposed(), x(this);
59
- }, l().prototype.avgPool = function(e, t, n, r) {
60
- return this.throwIfDisposed(), vt(this, e, t, n, r);
61
- }, l().prototype.batchToSpaceND = function(e, t) {
62
- return this.throwIfDisposed(), Pe(this, e, t);
63
- }, l().prototype.batchNorm = function(e, t, n, r, i) {
64
- return this.throwIfDisposed(), q(this, e, t, n, r, i);
65
- }, l().prototype.broadcastTo = function(e) {
66
- return this.throwIfDisposed(), ut(this, e);
67
- }, l().prototype.cast = function(e) {
68
- return this.throwIfDisposed(), U(this, e);
69
- }, l().prototype.ceil = function() {
70
- return this.throwIfDisposed(), nt(this);
71
- }, l().prototype.clipByValue = function(e, t) {
72
- return this.throwIfDisposed(), We(this, e, t);
73
- }, l().prototype.concat = function(e, t) {
74
- return this.throwIfDisposed(), e instanceof $ && (e = [e]), Se([this, ...e], t);
75
- }, l().prototype.conv1d = function(e, t, n, r, i, a) {
76
- return this.throwIfDisposed(), A(this, e, t, n, r, i, a);
77
- }, l().prototype.conv2dTranspose = function(e, t, n, r, i) {
78
- return this.throwIfDisposed(), _e(this, e, t, n, r, i);
79
- }, l().prototype.conv2d = function(t, n, r, i, a, o) {
80
- return this.throwIfDisposed(), e(this, t, n, r, i, a, o);
81
- }, l().prototype.cos = function() {
82
- return this.throwIfDisposed(), g(this);
83
- }, l().prototype.cosh = function() {
84
- return this.throwIfDisposed(), ce(this);
85
- }, l().prototype.cumprod = function(e, t, n) {
86
- return this.throwIfDisposed(), he(this, e, t, n);
87
- }, l().prototype.cumsum = function(e, t, n) {
88
- return this.throwIfDisposed(), R(this, e, t, n);
89
- }, l().prototype.depthToSpace = function(e, t) {
90
- return this.throwIfDisposed(), H(this, e, t);
91
- }, l().prototype.depthwiseConv2d = function(e, t, n, r, i, a) {
92
- return this.throwIfDisposed(), o(this, e, t, n, r, i, a);
93
- }, l().prototype.dilation2d = function(e, t, n, r, i) {
94
- return this.throwIfDisposed(), xt(this, e, t, n, r, i);
95
- }, l().prototype.divNoNan = function(e) {
96
- return this.throwIfDisposed(), b(this, e);
97
- }, l().prototype.div = function(e) {
98
- return this.throwIfDisposed(), u(this, e);
99
- }, l().prototype.dot = function(e) {
100
- return this.throwIfDisposed(), Ke(this, e);
101
- }, l().prototype.elu = function() {
102
- return this.throwIfDisposed(), r(this);
103
- }, l().prototype.equal = function(e) {
104
- return this.throwIfDisposed(), ie(this, e);
105
- }, l().prototype.erf = function() {
106
- return this.throwIfDisposed(), Je(this);
107
- }, l().prototype.euclideanNorm = function(e, t) {
108
- return this.throwIfDisposed(), Ne(this, e, t);
109
- }, l().prototype.exp = function() {
110
- return this.throwIfDisposed(), Ae(this);
111
- }, l().prototype.expandDims = function(e) {
112
- return this.throwIfDisposed(), pt(this, e);
113
- }, l().prototype.expm1 = function() {
114
- return this.throwIfDisposed(), Ye(this);
115
- }, l().prototype.fft = function() {
116
- return this.throwIfDisposed(), p(this);
117
- }, l().prototype.flatten = function() {
118
- return this.throwIfDisposed(), G(this, [this.size]);
119
- }, l().prototype.floor = function() {
120
- return this.throwIfDisposed(), tt(this);
121
- }, l().prototype.floorDiv = function(e) {
122
- return this.throwIfDisposed(), _(this, e);
123
- }, l().prototype.gather = function(e, t, n) {
124
- return this.throwIfDisposed(), we(this, e, t, n);
125
- }, l().prototype.greaterEqual = function(e) {
126
- return this.throwIfDisposed(), ct(this, e);
127
- }, l().prototype.greater = function(e) {
128
- return this.throwIfDisposed(), Ue(this, e);
129
- }, l().prototype.ifft = function() {
130
- return this.throwIfDisposed(), ot(this);
131
- }, l().prototype.irfft = function() {
132
- return this.throwIfDisposed(), h(this);
133
- }, l().prototype.isFinite = function() {
134
- return this.throwIfDisposed(), $e(this);
135
- }, l().prototype.isInf = function() {
136
- return this.throwIfDisposed(), ft(this);
137
- }, l().prototype.isNaN = function() {
138
- return this.throwIfDisposed(), je(this);
139
- }, l().prototype.leakyRelu = function(e) {
140
- return this.throwIfDisposed(), t(this, e);
141
- }, l().prototype.lessEqual = function(e) {
142
- return this.throwIfDisposed(), xe(this, e);
143
- }, l().prototype.less = function(e) {
144
- return this.throwIfDisposed(), j(this, e);
145
- }, l().prototype.localResponseNormalization = function(e, t, n, r) {
146
- return this.throwIfDisposed(), ve(this, e, t, n, r);
147
- }, l().prototype.logSigmoid = function() {
148
- return this.throwIfDisposed(), pe(this);
149
- }, l().prototype.logSoftmax = function(e) {
150
- return this.throwIfDisposed(), Ct(this, e);
151
- }, l().prototype.logSumExp = function(e, t) {
152
- return this.throwIfDisposed(), P(this, e, t);
153
- }, l().prototype.log = function() {
154
- return this.throwIfDisposed(), be(this);
155
- }, l().prototype.log1p = function() {
156
- return this.throwIfDisposed(), m(this);
157
- }, l().prototype.logicalAnd = function(e) {
158
- return this.throwIfDisposed(), y(this, e);
159
- }, l().prototype.logicalNot = function() {
160
- return this.throwIfDisposed(), f(this);
161
- }, l().prototype.logicalOr = function(e) {
162
- return this.throwIfDisposed(), oe(this, e);
163
- }, l().prototype.logicalXor = function(e) {
164
- return this.throwIfDisposed(), k(this, e);
165
- }, l().prototype.matMul = function(e, t, n) {
166
- return this.throwIfDisposed(), Le(this, e, t, n);
167
- }, l().prototype.maxPool = function(e, t, n, r) {
168
- return this.throwIfDisposed(), w(this, e, t, n, r);
169
- }, l().prototype.max = function(e, t) {
170
- return this.throwIfDisposed(), Ee(this, e, t);
171
- }, l().prototype.maximum = function(e) {
172
- return this.throwIfDisposed(), qe(this, e);
173
- }, l().prototype.mean = function(e, t) {
174
- return this.throwIfDisposed(), i(this, e, t);
175
- }, l().prototype.min = function(e, t) {
176
- return this.throwIfDisposed(), _t(this, e, t);
177
- }, l().prototype.minimum = function(e) {
178
- return this.throwIfDisposed(), c(this, e);
179
- }, l().prototype.mirrorPad = function(e, t) {
180
- return this.throwIfDisposed(), re(this, e, t);
181
- }, l().prototype.mod = function(e) {
182
- return this.throwIfDisposed(), I(this, e);
183
- }, l().prototype.mul = function(e) {
184
- return this.throwIfDisposed(), ge(this, e);
185
- }, l().prototype.neg = function() {
186
- return this.throwIfDisposed(), B(this);
187
- }, l().prototype.norm = function(e, t, n) {
188
- return this.throwIfDisposed(), it(this, e, t, n);
189
- }, l().prototype.notEqual = function(e) {
190
- return this.throwIfDisposed(), F(this, e);
191
- }, l().prototype.oneHot = function(e, t = 1, n = 0) {
192
- return this.throwIfDisposed(), gt(this, e, t, n);
193
- }, l().prototype.onesLike = function() {
194
- return this.throwIfDisposed(), De(this);
195
- }, l().prototype.pad = function(e, t) {
196
- return this.throwIfDisposed(), yt(this, e, t);
197
- }, l().prototype.pool = function(e, t, n, r, i, a) {
198
- return this.throwIfDisposed(), Ce(this, e, t, n, r, i, a);
199
- }, l().prototype.pow = function(e) {
200
- return this.throwIfDisposed(), Q(this, e);
201
- }, l().prototype.prelu = function(e) {
202
- return this.throwIfDisposed(), Re(this, e);
203
- }, l().prototype.prod = function(e, t) {
204
- return this.throwIfDisposed(), He(this, e, t);
205
- }, l().prototype.reciprocal = function() {
206
- return this.throwIfDisposed(), Z(this);
207
- }, l().prototype.relu = function() {
208
- return this.throwIfDisposed(), Xe(this);
209
- }, l().prototype.relu6 = function() {
210
- return this.throwIfDisposed(), ke(this);
211
- }, l().prototype.reshapeAs = function(e) {
212
- return this.throwIfDisposed(), G(this, e.shape);
213
- }, l().prototype.reshape = function(e) {
214
- return this.throwIfDisposed(), G(this, e);
215
- }, l().prototype.resizeBilinear = function(e, t, n) {
216
- return this.throwIfDisposed(), Fe(this, e, t, n);
217
- }, l().prototype.resizeNearestNeighbor = function(e, t, n) {
218
- return this.throwIfDisposed(), ze(this, e, t, n);
219
- }, l().prototype.reverse = function(e) {
220
- return this.throwIfDisposed(), dt(this, e);
221
- }, l().prototype.rfft = function() {
222
- return this.throwIfDisposed(), me(this);
223
- }, l().prototype.round = function() {
224
- return this.throwIfDisposed(), rt(this);
225
- }, l().prototype.rsqrt = function() {
226
- return this.throwIfDisposed(), Te(this);
227
- }, l().prototype.selu = function() {
228
- return this.throwIfDisposed(), Ge(this);
229
- }, l().prototype.separableConv2d = function(e, t, n, r, i, a) {
230
- return this.throwIfDisposed(), lt(this, e, t, n, r, i, a);
231
- }, l().prototype.sigmoid = function() {
232
- return this.throwIfDisposed(), Ve(this);
233
- }, l().prototype.sign = function() {
234
- return this.throwIfDisposed(), et(this);
235
- }, l().prototype.sin = function() {
236
- return this.throwIfDisposed(), X(this);
237
- }, l().prototype.sinh = function() {
238
- return this.throwIfDisposed(), Me(this);
239
- }, l().prototype.slice = function(e, t) {
240
- return this.throwIfDisposed(), Qe(this, e, t);
241
- }, l().prototype.softmax = function(e) {
242
- return this.throwIfDisposed(), ye(this, e);
243
- }, l().prototype.softplus = function() {
244
- return this.throwIfDisposed(), de(this);
245
- }, l().prototype.spaceToBatchND = function(e, t) {
246
- return this.throwIfDisposed(), mt(this, e, t);
247
- }, l().prototype.split = function(e, t) {
248
- return this.throwIfDisposed(), se(this, e, t);
249
- }, l().prototype.sqrt = function() {
250
- return this.throwIfDisposed(), Ie(this);
251
- }, l().prototype.square = function() {
252
- return this.throwIfDisposed(), Be(this);
253
- }, l().prototype.squaredDifference = function(e) {
254
- return this.throwIfDisposed(), L(this, e);
255
- }, l().prototype.squeeze = function(e) {
256
- return this.throwIfDisposed(), le(this, e);
257
- }, l().prototype.stack = function(e, t) {
258
- return this.throwIfDisposed(), V(e instanceof $ ? [this, e] : [this, ...e], t);
259
- }, l().prototype.step = function(e) {
260
- return this.throwIfDisposed(), a(this, e);
261
- }, l().prototype.stridedSlice = function(e, t, n, r, i, a, o, s) {
262
- return this.throwIfDisposed(), bt(this, e, t, n, r, i, a, o, s);
263
- }, l().prototype.sub = function(e) {
264
- return this.throwIfDisposed(), ee(this, e);
265
- }, l().prototype.sum = function(e, t) {
266
- return this.throwIfDisposed(), Ze(this, e, t);
267
- }, l().prototype.tan = function() {
268
- return this.throwIfDisposed(), M(this);
269
- }, l().prototype.tanh = function() {
270
- return this.throwIfDisposed(), at(this);
271
- }, l().prototype.tile = function(e) {
272
- return this.throwIfDisposed(), Oe(this, e);
273
- }, l().prototype.toBool = function() {
274
- return this.throwIfDisposed(), U(this, "bool");
275
- }, l().prototype.toFloat = function() {
276
- return this.throwIfDisposed(), U(this, "float32");
277
- }, l().prototype.toInt = function() {
278
- return this.throwIfDisposed(), U(this, "int32");
279
- }, l().prototype.topk = function(e, t) {
280
- return this.throwIfDisposed(), n(this, e, t);
281
- }, l().prototype.transpose = function(e) {
282
- return this.throwIfDisposed(), ht(this, e);
283
- }, l().prototype.unique = function(e) {
284
- return this.throwIfDisposed(), T(this, e);
285
- }, l().prototype.unsortedSegmentSum = function(e, t) {
286
- return this.throwIfDisposed(), te(this, e, t);
287
- }, l().prototype.unstack = function(e) {
288
- return this.throwIfDisposed(), ne(this, e);
289
- }, l().prototype.where = function(e, t) {
290
- return this.throwIfDisposed(), E(e, this, t);
291
- }, l().prototype.zerosLike = function() {
292
- return this.throwIfDisposed(), S(this);
293
- };
294
- //#endregion
295
- //#region lib/layers/RoPECache.ts
296
- var wt = class {
297
- config;
298
- rotaryDim;
299
- ropeBase;
300
- ropeInvFreq;
301
- ropeCos = null;
302
- ropeSin = null;
303
- ropeNegSin = null;
304
- ropeCacheLen = 0;
305
- constructor(e) {
306
- this.config = e;
307
- let t = this.config.nEmbed / this.config.nHead;
308
- if (this.rotaryDim = t, this.rotaryDim % 2 != 0) throw Error("rotaryDim must be even");
309
- let n = this.config.ropeTheta ?? 1e4;
310
- this.ropeBase = n;
311
- let r = J(0, this.rotaryDim, 2, "float32"), i = u(r, W(this.rotaryDim, "float32")), a = Q(W(this.ropeBase, "float32"), i);
312
- this.ropeInvFreq = Z(a), i.dispose(), a.dispose(), r.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) : K(() => {
313
- this.ensureRopeCache(this.config.blockSize * 4);
314
- });
315
- }
316
- ensureRopeCache(e) {
317
- K(() => {
318
- if (e <= this.ropeCacheLen) return;
319
- this.ropeCos && this.ropeCos.dispose(), this.ropeSin && this.ropeSin.dispose();
320
- let t = Math.max(e, this.ropeCacheLen + this.config.blockSize * 4), n = J(0, t, 1, "float32").expandDims(1).mul(this.ropeInvFreq.expandDims(0));
321
- this.ropeCos = Y(g(n).expandDims(-1)), this.ropeSin = Y(X(n).expandDims(-1)), this.ropeNegSin = Y(this.ropeSin.neg()), this.ropeCacheLen = t;
322
- });
323
- }
324
- getCos() {
325
- return this.ropeCos;
326
- }
327
- getSin() {
328
- return this.ropeSin;
329
- }
330
- getNegSin() {
331
- return this.ropeNegSin;
332
- }
333
- dispose() {
334
- this.ropeCos && this.ropeCos.dispose(), this.ropeSin && this.ropeSin.dispose(), this.ropeInvFreq.dispose();
335
- }
336
- };
337
- //#endregion
338
- export { wt as default };
1
+ export { t as default } from "../RoPECache-dYscFINl.js";
@@ -1,32 +1,33 @@
1
- import { T as e, an as t } from "../dist-Da20xy8E.js";
2
- import { n } from "../dist-CwK5S7Ls.js";
3
- import { isPackedTensor as r } from "../utilities/packed.js";
4
- import { transpose16 as i } from "../ops/transpose16.js";
5
- import { t as a } from "../pack16-BhuXNUS7.js";
6
- import o from "./BaseLayer.js";
7
- import { dot16 as s } from "../ops/dot16.js";
8
- //#region lib/layers/TiedEmbedding.ts
9
- var c = class extends o {
1
+ import { n as e } from "../dist-DyL7qSLJ.js";
2
+ import "../dist-CMMLi-qO.js";
3
+ import { t } from "../gather-B5Z1RFt5.js";
4
+ import { n } from "../picomatch--TW6gyBJ.js";
5
+ import r from "./BaseLayer.js";
6
+ import { dot16 as i } from "../ops/dot16.js";
7
+ import { isPackedTensor as a } from "../utilities/packed.js";
8
+ import { t as o } from "../pack16-BHO4t1-M.js";
9
+ import { transpose16 as s } from "../ops/transpose16.js";
10
+ // lib/layers/TiedEmbedding.ts
11
+ var c = class extends r {
10
12
  vocabSize;
11
13
  embedDim;
12
14
  initializer;
13
15
  WEIGHTS;
14
16
  constructor(t, r, i) {
15
- super(t, i), this.WEIGHTS = r, this.vocabSize = t.vocabSize, this.embedDim = t.nEmbed, this.initializer = n({
17
+ super(t, i), this.WEIGHTS = r, this.vocabSize = t.vocabSize, this.embedDim = t.nEmbed, this.initializer = e({
16
18
  mean: 0,
17
19
  stddev: .02
18
- }), this.addVariable(this.WEIGHTS, e(this.initializer.apply([this.vocabSize, this.embedDim]), !0, r));
20
+ }), this.addVariable(this.WEIGHTS, n(this.initializer.apply([this.vocabSize, this.embedDim]), !0, r));
19
21
  }
20
22
  embed(e) {
21
23
  return t(this.getVariable(this.WEIGHTS), e, 0);
22
24
  }
23
25
  project(e) {
24
- let t = r(e) ? a(this.getVariable(this.WEIGHTS), void 0, 32) : this.getVariable(this.WEIGHTS), n = i(t);
25
- return r(e) && t.dispose(), s(e, n);
26
+ let t = a(e) ? o(this.getVariable(this.WEIGHTS), void 0, 32) : this.getVariable(this.WEIGHTS), n = s(t);
27
+ return a(e) && t.dispose(), i(e, n);
26
28
  }
27
29
  forward(e, t) {
28
30
  return this.project(t);
29
31
  }
30
32
  };
31
- //#endregion
32
33
  export { c as default };
@@ -1,15 +1,10 @@
1
- import { AttentionScores, MHAConfig, KVCache } from './MHA';
1
+ import { MHAConfig, AttentionForwardAttributes } from './MHA';
2
2
  import { MLPConfig } from './MLP';
3
3
  import { RMSNormConfig } from './RMSNorm';
4
- import { default as BaseLayer, ForwardAttributes } from './BaseLayer';
4
+ import { default as BaseLayer } from './BaseLayer';
5
5
  import { Tensor } from '@tensorflow/tfjs-core';
6
6
  import { GPTConfig } from '../../models/config';
7
- interface BlockAttributes extends ForwardAttributes {
8
- pastKV?: KVCache;
9
- seed?: number;
10
- attentionScores?: AttentionScores;
11
- ropePositionOffset?: number;
12
- }
7
+ export type BlockAttributes = AttentionForwardAttributes;
13
8
  export type TransformerBlockConfig = MLPConfig & RMSNormConfig & MHAConfig;
14
9
  export default class Block extends BaseLayer<BlockAttributes> {
15
10
  private ln1;
@@ -24,4 +19,3 @@ export default class Block extends BaseLayer<BlockAttributes> {
24
19
  forward(attrs: BlockAttributes, x: Tensor): Tensor;
25
20
  dispose(): void;
26
21
  }
27
- export {};
@@ -1,11 +1,11 @@
1
- import { di as e, oi as t } from "../dist-Da20xy8E.js";
2
- import n from "./BaseLayer.js";
3
- import r from "./RMSNorm.js";
4
- import i from "./MHA.js";
5
- import a from "./MLP.js";
1
+ import e from "./MHA.js";
2
+ import t from "./MLP.js";
3
+ import n from "./RMSNorm.js";
4
+ import r from "./BaseLayer.js";
5
+ import { W as i, Y as a } from "../dist-CMMLi-qO.js";
6
6
  import { add16 as o } from "../ops/add16.js";
7
- //#region lib/layers/TransformerBlock.ts
8
- var s = class extends n {
7
+ // lib/layers/TransformerBlock.ts
8
+ var s = class extends r {
9
9
  ln1;
10
10
  attn;
11
11
  ln2;
@@ -13,39 +13,38 @@ var s = class extends n {
13
13
  index;
14
14
  skipped = !1;
15
15
  blockConfig;
16
- constructor(e, t, n, o) {
17
- super(t, o), this.index = e, this.blockConfig = n, this.ln1 = new r(t, this.blockConfig, `block_${this.index}_rms1`, this), this.attn = new i(this.index, t, this.blockConfig, this), this.ln2 = new r(t, this.blockConfig, `block_${this.index}_rms2`, this), this.mlp = new a(this.index, t, this.blockConfig, this);
16
+ constructor(r, i, a, o) {
17
+ super(i, o), this.index = r, this.blockConfig = a, this.ln1 = new n(i, this.blockConfig, `block_${this.index}_rms1`, this), this.attn = new e(this.index, i, this.blockConfig, this), this.ln2 = new n(i, this.blockConfig, `block_${this.index}_rms2`, this), this.mlp = new t(this.index, i, this.blockConfig, this);
18
18
  }
19
- getMLPOutput(e, n) {
20
- let r = this.ln2.call({ training: n.training }, e), i = this.mlp.call(n, r);
21
- n.outputEmbeddings ? (t(r), n.embeddings.push({
19
+ getMLPOutput(e, t) {
20
+ let n = this.ln2.call({ training: t.training }, e), r = this.mlp.call(t, n);
21
+ t.outputEmbeddings ? (i(n), t.embeddings.push({
22
22
  name: `block_ln2_${this.index}`,
23
- tensor: r
24
- })) : r.dispose();
25
- let a = o(e, i);
26
- return e.dispose(), n.outputEmbeddings ? (t(i), n.embeddings.push({
23
+ tensor: n
24
+ })) : n.dispose();
25
+ let a = o(e, r);
26
+ return e.dispose(), t.outputEmbeddings ? (i(r), t.embeddings.push({
27
27
  name: `block_mlp_out_${this.index}`,
28
- tensor: i
29
- })) : i.dispose(), a;
28
+ tensor: r
29
+ })) : r.dispose(), a;
30
30
  }
31
- forward(n, r) {
32
- return e(() => {
33
- if (this.skipped) return r;
34
- let e = this.ln1.call(n, r), i = this.attn.call(n, e);
35
- n.outputEmbeddings ? (t(e), n.embeddings.push({
31
+ forward(e, t) {
32
+ return a(() => {
33
+ if (this.skipped) return t;
34
+ let n = this.ln1.call(e, t), r = this.attn.call(e, n);
35
+ e.outputEmbeddings ? (i(n), e.embeddings.push({
36
36
  name: `block_ln1_${this.index}`,
37
- tensor: e
38
- })) : e.dispose();
39
- let a = o(r, i);
40
- return n.outputEmbeddings ? (t(i), n.embeddings.push({
37
+ tensor: n
38
+ })) : n.dispose();
39
+ let a = o(t, r);
40
+ return e.outputEmbeddings ? (i(r), e.embeddings.push({
41
41
  name: `block_attn_out_${this.index}`,
42
- tensor: i
43
- })) : i.dispose(), this.getMLPOutput(a, n);
42
+ tensor: r
43
+ })) : r.dispose(), this.getMLPOutput(a, e);
44
44
  });
45
45
  }
46
46
  dispose() {
47
47
  this.ln1.dispose(), this.attn.dispose(), this.ln2.dispose(), this.mlp.dispose();
48
48
  }
49
49
  };
50
- //#endregion
51
50
  export { s as default };
@@ -1,7 +1,7 @@
1
- import { i as e } from "../chunk-CWhphoD1.js";
2
- import { Jr as t, T as n } from "../dist-Da20xy8E.js";
3
- import { t as r } from "../picomatch-BO4HbNfo.js";
4
- //#region lib/layers/WeightStore.ts
1
+ import { i as e } from "../rolldown-runtime-CwxnZyOB.js";
2
+ import { M as t } from "../dist-CMMLi-qO.js";
3
+ import { n, t as r } from "../picomatch--TW6gyBJ.js";
4
+ // lib/layers/WeightStore.ts
5
5
  var i = /* @__PURE__ */ e(r(), 1), a = class {
6
6
  _variables = /* @__PURE__ */ new Map();
7
7
  touchedVariables = /* @__PURE__ */ new Set();
@@ -65,5 +65,4 @@ var i = /* @__PURE__ */ e(r(), 1), a = class {
65
65
  }), this._variables.clear();
66
66
  }
67
67
  };
68
- //#endregion
69
68
  export { a as default };
@@ -0,0 +1,13 @@
1
+ import { n as e } from "./rolldown-runtime-CwxnZyOB.js";
2
+ import t from "./layers/MHA.js";
3
+ import n from "./layers/MLP.js";
4
+ import r from "./layers/TransformerBlock.js";
5
+ import { t as i } from "./RoPECache-dYscFINl.js";
6
+ // lib/layers.ts
7
+ var a = /* @__PURE__ */ e({
8
+ CausalSelfAttention: () => t,
9
+ MLP: () => n,
10
+ RoPECache: () => i,
11
+ TransformerBlock: () => r
12
+ });
13
+ export { a as t };
package/dist/layers.js CHANGED
@@ -1,14 +1,6 @@
1
- import { n as e } from "./chunk-CWhphoD1.js";
1
+ import { t as e } from "./RoPECache-dYscFINl.js";
2
2
  import t from "./layers/MHA.js";
3
3
  import n from "./layers/MLP.js";
4
4
  import r from "./layers/TransformerBlock.js";
5
- import i from "./layers/RoPECache.js";
6
- //#region lib/layers.ts
7
- var a = /* @__PURE__ */ e({
8
- CausalSelfAttention: () => t,
9
- MLP: () => n,
10
- RoPECache: () => i,
11
- TransformerBlock: () => r
12
- });
13
- //#endregion
14
- export { t as CausalSelfAttention, n as MLP, i as RoPECache, r as TransformerBlock, a as t };
5
+ import "./layers-CFqEip3s.js";
6
+ export { t as CausalSelfAttention, n as MLP, e as RoPECache, r as TransformerBlock };
@@ -1,23 +1,23 @@
1
- import { i as e } from "../chunk-CWhphoD1.js";
2
- import { t } from "../jszip.min-DKa1Rjyn.js";
3
- import { load_safetensors as n } from "../utilities/safetensors.js";
4
- import r from "./oldZipLoad.js";
5
- import i from "./newZipLoad.js";
6
- import a from "./loadHF.js";
7
- import { loadZipMeta as o } from "./loadZipMeta.js";
8
- //#region lib/loader/load.ts
1
+ import { i as e } from "../rolldown-runtime-CwxnZyOB.js";
2
+ import { t } from "../jszip.min-Btv48m44.js";
3
+ import n from "./oldZipLoad.js";
4
+ import r from "./newZipLoad.js";
5
+ import i from "./loadHF.js";
6
+ import { loadZipMeta as a } from "./loadZipMeta.js";
7
+ import { load_safetensors as o } from "../utilities/safetensors.js";
8
+ // lib/loader/load.ts
9
9
  var s = /* @__PURE__ */ e(t(), 1), c = 2;
10
10
  async function l(e) {
11
11
  let t = await fetch(e);
12
12
  if (!t.ok) throw Error(`Failed to fetch ${e}: ${t.statusText}`);
13
13
  return t.arrayBuffer();
14
14
  }
15
- async function u(e, t, r) {
16
- let i = e.file("model.safetensors");
17
- if (!i) return;
18
- let a = await n(await i.async("arraybuffer")), o = /* @__PURE__ */ new Map();
19
- for (let [e, t] of Object.entries(a)) o.set(e, [t]);
20
- t.weightStore.loadWeights(o, r);
15
+ async function u(e, t, n) {
16
+ let r = e.file("model.safetensors");
17
+ if (!r) return;
18
+ let i = await r.async("arraybuffer"), a = await o(i), s = /* @__PURE__ */ new Map();
19
+ for (let [e, t] of Object.entries(a)) s.set(e, [t]);
20
+ t.weightStore.loadWeights(s, n);
21
21
  }
22
22
  async function d(e, t) {
23
23
  let n = e.file("config.json");
@@ -40,21 +40,24 @@ async function f(e, t) {
40
40
  ...t
41
41
  }
42
42
  };
43
- } else if (e.file("manifest.json")) return r(e, t);
44
- else {
45
- let n = await i(e, t);
43
+ }
44
+ if (e.file("manifest.json")) return n(e, t);
45
+ {
46
+ let n = await r(e, t);
46
47
  return n.model.config.loraName && n.model.attachLoRA(n.model.config.loraName), n;
47
48
  }
48
49
  }
49
50
  async function p(e, t) {
50
- if (typeof e == "string") if (e.startsWith("http://") || e.startsWith("https://")) {
51
- let t = await l(e), n = await s.default.loadAsync(t), r = await o(n);
52
- return r.url = e, f(n, r);
53
- } else return a(e);
54
- else {
55
- let n = await s.default.loadAsync(e), r = await o(n);
51
+ if (typeof e == "string") {
52
+ if (e.startsWith("http://") || e.startsWith("https://")) {
53
+ let t = await l(e), n = await s.default.loadAsync(t), r = await a(n);
54
+ return r.url = e, f(n, r);
55
+ }
56
+ return i(e);
57
+ }
58
+ {
59
+ let n = await s.default.loadAsync(e), r = await a(n);
56
60
  return r.url = t?.sourceURL || void 0, f(n, r);
57
61
  }
58
62
  }
59
- //#endregion
60
63
  export { c as VERSION, p as loadModel };
@@ -1,5 +1,5 @@
1
1
  import e from "./loadTransformers.js";
2
- //#region lib/loader/loadHF.ts
2
+ // lib/loader/loadHF.ts
3
3
  async function t(t) {
4
4
  let n = `https://huggingface.co/${t}/resolve/main/config.json`, r = `https://huggingface.co/${t}/resolve/main/tokeniser.json`, i = `https://huggingface.co/${t}/resolve/main/meta.json`, a = `https://huggingface.co/${t}/resolve/main/model.safetensors`, [o, s, c, l] = await Promise.all([
5
5
  fetch(n),
@@ -11,7 +11,7 @@ async function t(t) {
11
11
  if (!s.ok) throw Error(`Failed to fetch tokeniser from ${r}: ${s.statusText}`);
12
12
  if (!c.ok) throw Error(`Failed to fetch meta from ${i}: ${c.statusText}`);
13
13
  if (!l.ok) throw Error(`Failed to fetch weights from ${a}: ${l.statusText}`);
14
- return e(await o.json(), await s.json(), await c.json(), await l.arrayBuffer());
14
+ let u = await o.json(), d = await s.json(), f = await c.json(), p = await l.arrayBuffer();
15
+ return e(u, d, f, p);
15
16
  }
16
- //#endregion
17
17
  export { t as default };