jev-web 0.2.0 → 0.2.1
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 +1 -1
- package/src/laya.mjs +16 -1
- package/src/session.mjs +8 -1
package/package.json
CHANGED
package/src/laya.mjs
CHANGED
|
@@ -216,6 +216,13 @@ export function layaTokenizerAdapter(tok) {
|
|
|
216
216
|
};
|
|
217
217
|
return {
|
|
218
218
|
encode: (text) => Array.from(tok(text, { add_special_tokens: false }).input_ids.data, Number),
|
|
219
|
+
decode: (ids) => {
|
|
220
|
+
try {
|
|
221
|
+
return tok.decode(Array.from(ids), { skip_special_tokens: false });
|
|
222
|
+
} catch {
|
|
223
|
+
return Array.from(ids).join(" ");
|
|
224
|
+
}
|
|
225
|
+
},
|
|
219
226
|
ids: {
|
|
220
227
|
cls: idOf("cls_token_id", "[CLS]"),
|
|
221
228
|
sep: idOf("sep_token_id", "[SEP]"),
|
|
@@ -376,7 +383,15 @@ export async function createLayaDecider({
|
|
|
376
383
|
temperatureByOptions,
|
|
377
384
|
});
|
|
378
385
|
const length = Number(b.attention.reduce((a, v) => a + v, 0n));
|
|
379
|
-
|
|
386
|
+
// Exact, human-readable view of what the encoder consumed: each
|
|
387
|
+
// question's token sequence decoded back to text (special tokens kept).
|
|
388
|
+
const prompts = items.map((it) => adapter.decode(it.ids));
|
|
389
|
+
return {
|
|
390
|
+
answers,
|
|
391
|
+
truncated: items.some((it) => it.ids.length >= maxLen),
|
|
392
|
+
length,
|
|
393
|
+
prompts,
|
|
394
|
+
};
|
|
380
395
|
},
|
|
381
396
|
async dispose() {
|
|
382
397
|
try { await encoder.release?.(); } catch { /* optional */ }
|
package/src/session.mjs
CHANGED
|
@@ -118,7 +118,14 @@ export async function createDecider({
|
|
|
118
118
|
groups: input.groups,
|
|
119
119
|
temperature: effective.temperature,
|
|
120
120
|
});
|
|
121
|
-
|
|
121
|
+
// Exact view of the single fused sequence the graph consumed.
|
|
122
|
+
let prompt;
|
|
123
|
+
try {
|
|
124
|
+
prompt = tokenizer.decode(input.inputIds, { skip_special_tokens: false });
|
|
125
|
+
} catch {
|
|
126
|
+
prompt = input.inputIds.join(" ");
|
|
127
|
+
}
|
|
128
|
+
return { answers, truncated: input.truncated, length: input.length, prompts: [prompt] };
|
|
122
129
|
},
|
|
123
130
|
async decideMany(cases) {
|
|
124
131
|
const out = [];
|