@imaduddin/fastbrain 1.0.8 → 1.0.9

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": "@imaduddin/fastbrain",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Raw-JAVASCRIPT Based Matirx and AI LLM Package called fastBrain.",
5
5
  "keywords": [
6
6
  "ai",
@@ -124,7 +124,7 @@ export class Softmax {
124
124
  if(!encoder2) await this.gpu.submitQueue(encoder)
125
125
  return this.dLogits
126
126
  }
127
- async crossEntropy(probs, target) {
127
+ async crossEntropy(probs, target, encoderMain) {
128
128
  const encoder = encoderMain ? encoderMain : this.device.createCommandEncoder();
129
129
  const tokenCount = probs.size / (this.vocabSize * Float32Array.BYTES_PER_ELEMENT);
130
130
  if (!Number.isInteger(tokenCount) || tokenCount <= 0) {
@@ -47,7 +47,7 @@ fn main(@builtin(workgroup_id) wid: vec3<u32>, @builtin(local_invocation_id) lid
47
47
 
48
48
  if (tokens > 0u) {
49
49
  let idx = weightBase + j;
50
- weight[idx] -= params.lr * (grad / f32(tokens));
50
+ weight[idx] -= params.lr * grad;
51
51
  }
52
52
  }
53
53
 
@@ -66,6 +66,6 @@ fn main(@builtin(workgroup_id) wid: vec3<u32>, @builtin(local_invocation_id) lid
66
66
  }
67
67
 
68
68
  if (tid == 0u && tokens > 0u) {
69
- bias[outputIndex] -= params.lr * (sharedBias[0] / f32(tokens));
69
+ bias[outputIndex] -= params.lr * sharedBias[0];
70
70
  }
71
71
  }