@mineproness/tensorloop 1.5.7 → 1.5.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mineproness/tensorloop",
3
- "version": "1.5.7",
3
+ "version": "1.5.8",
4
4
  "description": "Raw-JAVASCRIPT Based Matirx and AI LLM Package called Tensorloop.",
5
5
  "keywords": [
6
6
  "ai",
@@ -1,5 +1,6 @@
1
1
  import fs, { existsSync } from 'fs'
2
2
  import { SaveVectors, LoadVectors } from '../GetConfigs.js'
3
+ import { GPUEmbedding } from '../GPU.js'
3
4
  // import { config } from 'process'
4
5
 
5
6
  function GenerateVectors(embeddingSize, vocabSize) {
@@ -17,6 +18,7 @@ export class Embedding {
17
18
  vectors = []
18
19
  configs;
19
20
  embeddingSize = 0
21
+
20
22
  constructor(embeddingSize, vocabSize, configs) {
21
23
  this.configs = configs
22
24
  this.embeddingSize = embeddingSize
@@ -25,12 +27,12 @@ export class Embedding {
25
27
  this.vectors = LoadVectors(configs.save.filename, embeddingSize)
26
28
  } else {
27
29
  this.vectors = GenerateVectors(embeddingSize, vocabSize)
28
- this.Save()
30
+ SaveVectors(this.vectors, this.configs.save.filename)
29
31
  }
30
32
  } else {
31
33
  this.vectors = GenerateVectors(embeddingSize, vocabSize)
32
-
33
- }
34
+
35
+ }
34
36
  }
35
37
  forward(token) {
36
38
  if (Array.isArray(token)) {
package/src/GPU.js CHANGED
@@ -9,8 +9,8 @@ const kernel = gpu.createKernel(function () {
9
9
 
10
10
  kernel()
11
11
  const gl = kernel.context
12
-
13
- export function splitMatrix(matrix, chunksSizes = gl.getParameter(gl.MAX_TEXTURE_SIZE)) {
12
+ const maxSize = gl ? gl.getParameter(gl.MAX_TEXTURE_SIZE) : 1200
13
+ export function splitMatrix(matrix, chunksSizes = maxSize) {
14
14
  const chunks = []
15
15
  for (let a = 0; a < matrix.length; a += chunksSizes) {
16
16
  chunks.push(matrix.slice(a, a + chunksSizes))
@@ -143,4 +143,18 @@ export class GPULinear {
143
143
  this.Bias.map((e)=> bias.push(...e.toArray()))
144
144
  return { weights: weight, bias: new Float32Array(bias)}
145
145
  }
146
+ }
147
+
148
+ export class GPUEmbedding{
149
+ cacheEF;
150
+ constructor(embeddingSize){
151
+ this.cacheEF = gpu.createKernel(function(inputGradient, learningRate, tokenVector){
152
+ return tokenVector[this.thread.x] - (learningRate * inputGradient[this.thread.x])
153
+ }).setOutput([embeddingSize])
154
+ }
155
+ backward(tokenVector, inputGradient, learingRate){
156
+ return this.cacheEF(inputGradient, learingRate, tokenVector)
157
+ }
158
+
159
+
146
160
  }
package/model/ffnBias.bin DELETED
Binary file
Binary file
Binary file
Binary file