@mineproness/tensorloop 1.5.9 → 2.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mineproness/tensorloop",
3
- "version": "1.5.9",
3
+ "version": "2.0.0",
4
4
  "description": "Raw-JAVASCRIPT Based Matirx and AI LLM Package called Tensorloop.",
5
5
  "keywords": [
6
6
  "ai",
@@ -22,9 +22,9 @@ export class SelfAttention {
22
22
  this.value = new Linear(embeddingSize, embeddingSize, { save: { filename: [`${configs.dirname}/value.bin`, `${configs.dirname}/valueBias.bin`] } })
23
23
  }
24
24
  forward(vectors) {
25
- this.q = vectors.map((e) => this.query.forward(e))
26
- this.v = vectors.map((e) => this.value.forward(e))
27
- this.k = vectors.map((e) => this.key.forward(e))
25
+ this.q = this.query.forward(vectors)
26
+ this.v = this.value.forward(vectors)
27
+ this.k = this.key.forward(vectors)
28
28
  const attentionSocres = []
29
29
  for (let i = 0; i < this.q.length; i++) {
30
30
  attentionSocres[i] = new Float32Array(this.k.length);
@@ -44,7 +44,8 @@ export class SelfAttention {
44
44
  attentionSocres[i][j] = dot / this.score;
45
45
  }
46
46
  }
47
- const weights = attentionSocres.map((e) => this.softmax.forward(e))
47
+ this.softmax.forward(attentionSocres)
48
+ const weights = this.softmax.getSoftmaxes()
48
49
  this.weights = weights
49
50
  const output = [];
50
51
 
@@ -123,4 +124,9 @@ export class SelfAttention {
123
124
  this.key.Save()
124
125
  this.value.Save()
125
126
  }
127
+ ClearInputCache(){
128
+ this.query.ClearInputCache()
129
+ this.key.ClearInputCache()
130
+ this.value.ClearInputCache()
131
+ }
126
132
  }
@@ -2,5 +2,5 @@ export class Softmax{
2
2
  forward(xLi : number[]) : number
3
3
  backward(target : number[]) : Float32Array[]
4
4
  getSoftmaxes() : Float32Array[]
5
- crossEntropy(probs: Float32Array[], target: number[])
5
+ crossEntropy(dLogits: Float32Array[], target: number[])
6
6
  }