@mineproness/tensorloop 1.5.1 → 1.5.3
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/index.js +0 -2
- package/package.json +2 -3
- package/readme.md +8 -12
- package/src/Tokenizer/index.js +1 -2
- package/src/Tokenizer/vocabs.json +9 -1
- package/src/TransformerBlock/index.js +3 -8
- package/src/tools/index.d.ts +0 -3
- package/src/tools/index.js +0 -5
package/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import { Embedding as embeddding2 } from "./src/Embedding/index.js";
|
|
|
3
3
|
import { Linear as li2 } from "./src/Linear/index.js";
|
|
4
4
|
import { Softmax as softmax2 } from "./src/Softmax/index.js";
|
|
5
5
|
import { crossEntropy } from "./src/crossEntropy/index.js";
|
|
6
|
-
import {tools} from './src/tools/index.js'
|
|
7
6
|
import {ReLU} from './src/ReLU/index.js'
|
|
8
7
|
import {PositionEmbedding as PE} from './src/PositionEmbedding/index.js'
|
|
9
8
|
import {SelfAttention as ST} from './src/SelfAttention/index.js'
|
|
@@ -15,7 +14,6 @@ export const Embedding = embeddding2
|
|
|
15
14
|
export const Linear = li2
|
|
16
15
|
export const Softmax = softmax2
|
|
17
16
|
export const CrossEntropy = crossEntropy
|
|
18
|
-
export const Tools = tools
|
|
19
17
|
export const ReLu = ReLU
|
|
20
18
|
export const PositionEmbedding = PE
|
|
21
19
|
export const SelfAttention = ST
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mineproness/tensorloop",
|
|
3
|
-
"version": "1.5.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.5.3",
|
|
4
|
+
"description": "Raw-JAVASCRIPT Based Matirx and AI LLM Package called Tensorloop.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
7
7
|
"llm",
|
|
@@ -20,5 +20,4 @@
|
|
|
20
20
|
"type": "git",
|
|
21
21
|
"url": "https://github.com/mineproness-org/tensorloop.git"
|
|
22
22
|
}
|
|
23
|
-
|
|
24
23
|
}
|
package/readme.md
CHANGED
|
@@ -14,7 +14,7 @@ A high-performance JavaScript library that provides essential AI and Large Langu
|
|
|
14
14
|
- **Attention & Positioning**: Built-in **Self-Attention** and **Positional Embedding** matrices.
|
|
15
15
|
- **Text Processing**: Built-in **Tokenizer** to convert raw text into token IDs and back.
|
|
16
16
|
- **Special Tokens**: Native support for `<PAD>` and `<EOS>`.
|
|
17
|
-
|
|
17
|
+
- **FFN BLOCK**: It add a layer to understand Complex Patterns.
|
|
18
18
|
---
|
|
19
19
|
|
|
20
20
|
## 🏗 Core Architecture
|
|
@@ -93,7 +93,7 @@ const text = "Hello, Welcome to My Channel."
|
|
|
93
93
|
|
|
94
94
|
// Encode text to token IDs
|
|
95
95
|
const { tokenIDs } = tokenizer.encoder(text)
|
|
96
|
-
console.log(tokenIDs) // Output example: ["hello", "
|
|
96
|
+
console.log(tokenIDs) // Output example: ["hello", "$12", "well", "come", "$130"...]
|
|
97
97
|
|
|
98
98
|
// Decode token IDs back to text
|
|
99
99
|
const decoded = tokenizer.decoder(tokenIDs)
|
|
@@ -107,19 +107,15 @@ console.log(decoded) // Output: "Hello, Welcome to My Channel."
|
|
|
107
107
|
### 1. Use TypeScript
|
|
108
108
|
We highly recommend using **TypeScript** with TensorLoop to enforce type safety and leverage IDE autocomplete features for all active classes and methods.
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
Maximize efficiency by processing your layers with our built-in `Tools` utility suite:
|
|
112
|
-
|
|
113
|
-
```javascript
|
|
114
|
-
import { Tools } from '@mineproness/tensorloop'
|
|
115
|
-
|
|
116
|
-
const tools = new Tools()
|
|
110
|
+
---
|
|
117
111
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
```
|
|
112
|
+
### 2. Always use NodeJS 20 Higher
|
|
113
|
+
This Package optimized for node js 20 or higher. If you use older version it Maybe Break Easliy.
|
|
121
114
|
|
|
122
115
|
---
|
|
116
|
+
### 3. Use GELU Always.
|
|
117
|
+
|
|
118
|
+
Gelu is Better Activation because it is not turn a gradient 0 so it is so smoothly works.
|
|
123
119
|
|
|
124
120
|
## ⭐ Support the Project
|
|
125
121
|
|
package/src/Tokenizer/index.js
CHANGED
|
@@ -70,7 +70,7 @@ export class Tokenizer {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
return Validate(output.filter(e=> e.trim().length > 0)).join(" ").replaceAll(/\s+([,.;'{}
|
|
73
|
+
return Validate(output.filter(e=> e.trim().length > 0)).join(" ").replaceAll(/\s+([,.;'{}`!~\"?])/g, "$1")
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -86,7 +86,6 @@ function Validate(output = ["hello", "guys"]) {
|
|
|
86
86
|
bestOutput[idx] = e[0].toLocaleUpperCase() + e.slice(1, e.length)
|
|
87
87
|
} else {
|
|
88
88
|
bestOutput[idx] = e
|
|
89
|
-
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
|
|
@@ -19606,5 +19606,13 @@
|
|
|
19606
19606
|
"?",
|
|
19607
19607
|
"!",
|
|
19608
19608
|
"@",
|
|
19609
|
-
"$"
|
|
19609
|
+
"$",
|
|
19610
|
+
":",
|
|
19611
|
+
"/",
|
|
19612
|
+
"+",
|
|
19613
|
+
"-",
|
|
19614
|
+
"=",
|
|
19615
|
+
"%",
|
|
19616
|
+
"*",
|
|
19617
|
+
"@"
|
|
19610
19618
|
]
|
|
@@ -9,16 +9,11 @@ export class TransformerBlock {
|
|
|
9
9
|
}
|
|
10
10
|
forward(input) {
|
|
11
11
|
const attention = this.selfAttention.forward(input)
|
|
12
|
-
return this.ffn.forward(
|
|
12
|
+
return this.ffn.forward(attention)
|
|
13
13
|
}
|
|
14
14
|
backward(dOutput, learningRate) {
|
|
15
|
-
const dAttention =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return this.selfAttention.backward(
|
|
19
|
-
dAttention,
|
|
20
|
-
learningRate
|
|
21
|
-
)
|
|
15
|
+
const dAttention = this.ffn.backward(dOutput, learningRate)
|
|
16
|
+
return this.selfAttention.backward(dAttention, learningRate)
|
|
22
17
|
}
|
|
23
18
|
clearInputCache() {
|
|
24
19
|
this.ffn.ClearInputCache()
|
package/src/tools/index.d.ts
DELETED