@mineproness/tensorloop 2.1.63 → 2.1.64
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
package/src/Embedding/index.js
CHANGED
|
@@ -98,7 +98,7 @@ export class Embedding {
|
|
|
98
98
|
this.param = await this.gpu.createUniFormBuffer(this.oldParam.byteLength);
|
|
99
99
|
this.tokenBuffer = await this.gpu.createBuffer(4 * token.length)
|
|
100
100
|
}
|
|
101
|
-
if (this.oldParam[
|
|
101
|
+
if (this.oldParam[0] !== lr) {
|
|
102
102
|
this.oldParam = new Float32Array([lr, 0]);
|
|
103
103
|
this.gpu.WriteBuffer(this.param, this.oldParam)
|
|
104
104
|
}
|
package/src/Tokenizer/index.js
CHANGED
|
@@ -27,7 +27,7 @@ export class Tokenizer {
|
|
|
27
27
|
const output = []
|
|
28
28
|
for (let a = 0; a < splitedWords.length; a++) {
|
|
29
29
|
const word = splitedWords[a]
|
|
30
|
-
if (this.WordtoID[word]) {
|
|
30
|
+
if (this.WordtoID[word] !== undefined) {
|
|
31
31
|
output.push(word)
|
|
32
32
|
} else {
|
|
33
33
|
let max = word.length
|
|
@@ -36,7 +36,7 @@ export class Tokenizer {
|
|
|
36
36
|
const regPatten = new RegExp(`.{0,${max}}`, "g")
|
|
37
37
|
const wordsliced = word.match(regPatten).filter((e) => e.length > 0)
|
|
38
38
|
const matched = wordsliced.flatMap(e => {
|
|
39
|
-
if (this.WordtoID[e]) {
|
|
39
|
+
if (this.WordtoID[e] !== undefined) {
|
|
40
40
|
return true
|
|
41
41
|
}
|
|
42
42
|
return false
|
|
@@ -23,13 +23,8 @@ var <uniform> params: Params;
|
|
|
23
23
|
@compute @workgroup_size(4)
|
|
24
24
|
|
|
25
25
|
fn main(@builtin(global_invocation_id) id : vec3<u32>) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let
|
|
29
|
-
let start = token * params.vocabSize;
|
|
30
|
-
let end = start + params.vocabSize;
|
|
31
|
-
var targetIndex = targetToken[token];
|
|
32
|
-
let total: u32 = params.tokenCount * params.vocabSize;
|
|
33
|
-
let probalitils = probs[token * params.vocabSize + u32(targetIndex)];
|
|
26
|
+
let index = id.x;
|
|
27
|
+
var targetIndex = targetToken[index];
|
|
28
|
+
let probalitils = probs[index * params.vocabSize + u32(targetIndex)];
|
|
34
29
|
loss[index] = -log(probalitils + 1e-15);
|
|
35
30
|
}
|