@mineproness/tensorloop 2.1.51 → 2.1.53

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.51",
3
+ "version": "2.1.53",
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 { Embedding, PositionEmbedding, Linear, Tokenizer, TransformerBlock, Softmax } from '../../index.js'
2
2
  import path, { join } from 'path'
3
+ import { GPUThings } from '../gpiInit.js'
3
4
  export default class Model {
4
5
  embedding;
5
6
  linear;
@@ -40,13 +41,14 @@ export default class Model {
40
41
  train(text = "", epochs = 500, learningRate = 0.01) {
41
42
  process.stdout.write("\x1Bc")
42
43
  console.log("Preparing Training Pairs....")
43
- const tokens = text.split(/\r?\n/).map((e) => e.trim()).filter((e) => e.length > 0).map((e)=> e + " <EOS>").map((e) => this.tokenizer.encoder(e).tokenIDs).flat()
44
+ const tokens = text.split(/\r?\n/).map((e) => e.trim()).filter((e) => e.length > 0).map((e) => e + " <EOS>").map((e) => this.tokenizer.encoder(e).tokenIDs).flat()
44
45
  const trainingPair = []
45
46
  for (let a = 0; a + this.contextSize < tokens.length; a++) {
46
47
  trainingPair.push({
47
48
  inputIDX: tokens.slice(a, a + this.contextSize),
48
49
  targetIDX: tokens.slice(a + 1, a + this.contextSize + 1)
49
50
  })
51
+ if (trainingPair.length == 4000) break;
50
52
  }
51
53
  let firstRun = true;
52
54
  console.log(`TotalPairs: ${trainingPair.length}`)
@@ -78,6 +80,7 @@ export default class Model {
78
80
  const percentense = (((a + 1) / trainingPair.length) * 100).toFixed(2)
79
81
  const filted = Math.round((percentense / 100) * 20);
80
82
  const empty = 20 - filted
83
+
81
84
  process.stdout.write(`\rEPOCHS: ${i} [${"=".repeat(filted)}${" ".repeat(empty)}] ${percentense}% (${a + 1}/${trainingPair.length}) | loss ${(totalLoss / (a + 1)).toFixed(2)}`)
82
85
  }
83
86
  console.log("")
package/src/gpiInit.js CHANGED
@@ -737,7 +737,8 @@ export class GPUPosition {
737
737
  this.cachePF = gpu.createKernel(function (posVectors, vectors) {
738
738
  return vectors[this.thread.y][this.thread.x] + posVectors[this.thread.y][this.thread.x]
739
739
  }, {
740
- output: [embeddingSize, contextSize]
740
+ output: [embeddingSize, contextSize],
741
+
741
742
  })
742
743
  this.cachePB = gpu.createKernel(function (outGradient, learingRate, oldVec) {
743
744
  return oldVec[this.thread.y][this.thread.x] - learingRate * outGradient[this.thread.y][this.thread.x]
@@ -747,15 +748,17 @@ export class GPUPosition {
747
748
  pipeline: true,
748
749
  })
749
750
  }
750
- forward(vectors){
751
+ forward(vectors) {
751
752
  return this.cachePF(this.posVectors, vectors)
752
753
  }
753
- backward(outGradient, learingRate){
754
+ backward(outGradient, learingRate) {
754
755
  const oldVec = this.posVectors;
755
756
  this.posVectors = this.cachePB(outGradient, learingRate, oldVec)
756
757
  oldVec.delete()
757
758
  }
758
- Save(){
759
+ Save() {
759
760
  return this.posVectors.toArray()
760
761
  }
761
- }
762
+ }
763
+
764
+