@mineproness/tensorloop 2.1.58 → 2.1.60

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": "2.1.58",
3
+ "version": "2.1.60",
4
4
  "description": "Raw-JAVASCRIPT Based Matirx and AI LLM Package called Tensorloop.",
5
5
  "keywords": [
6
6
  "ai",
@@ -42,7 +42,7 @@ export class Linear {
42
42
  let total = embeddingSize * vocabSize;
43
43
  if (configs && configs.save) {
44
44
  const w = getVector(configs.save.filename[0], total);
45
- const b = getVector(configs.save.filename[1], total, true)
45
+ const b = getVector(configs.save.filename[1], vocabSize, true)
46
46
  if (!w && !b) {
47
47
  this.bias = GenerateBias(vocabSize)
48
48
  this.weights = GenerateVectors(embeddingSize, vocabSize)
@@ -63,7 +63,6 @@ export class SelfAttention {
63
63
  const finalOutput = await this.gpu.createBuffer(tokenCount * this.embeddingSize * 4)
64
64
  const outputBind = await this.gpu.createBindGroup(this.outputForward, 0, [this.weights, this.value, finalOutput, this.asParams]);
65
65
  await this.gpu.RunPipline(encoder, this.outputForward, outputBind, Math.ceil((tokenCount * this.embeddingSize) / 256))
66
-
67
66
  await this.gpu.submitQueue(encoder)
68
67
  scroes.destroy()
69
68
  return finalOutput
@@ -114,7 +113,7 @@ export class SelfAttention {
114
113
  }
115
114
  async Save(){
116
115
  await this.q.Save()
117
- await this.q.Save()
118
- await this.q.Save()
116
+ await this.k.Save()
117
+ await this.v.Save()
119
118
  }
120
119
  }
package/src/getVec.js CHANGED
@@ -5,21 +5,23 @@ export function getVector(filename, size, bias) {
5
5
  if (!fs.existsSync(filename)) {
6
6
  return null;
7
7
  }
8
- const bufferFloat32Array = fs.readFileSync(filename)
9
- const r = new Float32Array(bufferFloat32Array.buffer, bufferFloat32Array.byteOffset, bufferFloat32Array.byteLength / 4);
10
- if (r.length < size) {
11
- const output = new Float32Array(size);
12
- for(let a = 0; a < size; a++){
13
- let num = r[a];
14
- if(num){
15
- output[a] = num;
16
- }else{
17
- output[a] = bias ? 0 : (Math.random() * 2 - 1) * 0.02
18
- }
19
- }
20
- } else {
21
- return r
8
+ const buffer = fs.readFileSync(filename);
9
+ const r = new Float32Array(
10
+ buffer.buffer,
11
+ buffer.byteOffset,
12
+ buffer.byteLength / 4
13
+ );
14
+ if (r.length >= size) {
15
+ return r;
22
16
  }
17
+ const output = new Float32Array(size);
18
+ output.set(r);
19
+ if (!bias) {
20
+ for (let i = r.length; i < size; i++) {
21
+ output[i] = (Math.random() * 2 - 1) * 0.02;
22
+ }
23
+ }
24
+ return output;
23
25
  }
24
26
 
25
27
  export function SaveVector(filename, vectors) {
@@ -27,5 +27,5 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
27
27
  }
28
28
  let p = P[index];
29
29
  let dp = dP[index];
30
- output[index] = clamp(p * (dp - dot), -1.0, 1.0);
30
+ output[index] = p * (dp - dot);
31
31
  }