Update index.html
Browse files- index.html +5 -2
index.html
CHANGED
|
@@ -1161,7 +1161,9 @@
|
|
| 1161 |
const generationEnd = performance.now();
|
| 1162 |
const totalTime = generationEnd - generationStart;
|
| 1163 |
const inputTokenCount = inputs.input_ids.dims[1];
|
| 1164 |
-
|
|
|
|
|
|
|
| 1165 |
const tps = outputTokenCount / (totalTime / 1000);
|
| 1166 |
|
| 1167 |
// Store metrics
|
|
@@ -1172,6 +1174,7 @@
|
|
| 1172 |
console.log(`📊 Performance Metrics:`);
|
| 1173 |
console.log(` - Total generation time: ${totalTime.toFixed(2)}ms`);
|
| 1174 |
console.log(` - Input tokens: ${inputTokenCount}`);
|
|
|
|
| 1175 |
console.log(` - Output tokens: ${outputTokenCount}`);
|
| 1176 |
console.log(` - Tokens Per Second (TPS): ${tps.toFixed(2)} tok/s`);
|
| 1177 |
|
|
@@ -1179,7 +1182,7 @@
|
|
| 1179 |
document.getElementById("metric-ttft").innerText = `${ttft.toFixed(0)}ms`;
|
| 1180 |
document.getElementById("metric-tps").innerText = `${tps.toFixed(1)} t/s`;
|
| 1181 |
|
| 1182 |
-
const decoded = tokenizer.decode(output.slice(
|
| 1183 |
// 5. Parse Output
|
| 1184 |
// Format: <start_function_call>call:add{...}<end_function_call>
|
| 1185 |
const startTag = "<start_function_call>";
|
|
|
|
| 1161 |
const generationEnd = performance.now();
|
| 1162 |
const totalTime = generationEnd - generationStart;
|
| 1163 |
const inputTokenCount = inputs.input_ids.dims[1];
|
| 1164 |
+
// Handle tensor/array output properly
|
| 1165 |
+
const totalTokenCount = Array.isArray(output) ? output.length : (output.size || output.length || 0);
|
| 1166 |
+
const outputTokenCount = Math.max(0, totalTokenCount - inputTokenCount);
|
| 1167 |
const tps = outputTokenCount / (totalTime / 1000);
|
| 1168 |
|
| 1169 |
// Store metrics
|
|
|
|
| 1174 |
console.log(`📊 Performance Metrics:`);
|
| 1175 |
console.log(` - Total generation time: ${totalTime.toFixed(2)}ms`);
|
| 1176 |
console.log(` - Input tokens: ${inputTokenCount}`);
|
| 1177 |
+
console.log(` - Total tokens: ${totalTokenCount}`);
|
| 1178 |
console.log(` - Output tokens: ${outputTokenCount}`);
|
| 1179 |
console.log(` - Tokens Per Second (TPS): ${tps.toFixed(2)} tok/s`);
|
| 1180 |
|
|
|
|
| 1182 |
document.getElementById("metric-ttft").innerText = `${ttft.toFixed(0)}ms`;
|
| 1183 |
document.getElementById("metric-tps").innerText = `${tps.toFixed(1)} t/s`;
|
| 1184 |
|
| 1185 |
+
const decoded = tokenizer.decode(output.slice(inputs.input_ids.dims[1]), { skip_special_tokens: false });
|
| 1186 |
// 5. Parse Output
|
| 1187 |
// Format: <start_function_call>call:add{...}<end_function_call>
|
| 1188 |
const startTag = "<start_function_call>";
|