Spaces:
Running
Running
ping98k commited on
Commit ·
00182d4
1
Parent(s): 0adca4d
Refine cluster name extraction in K-Means implementation to handle special tokens and improve naming accuracy
Browse files
main.js
CHANGED
|
@@ -166,7 +166,11 @@ document.getElementById("kmeans-btn").onclick = async () => {
|
|
| 166 |
do_sample: false,
|
| 167 |
streamer,
|
| 168 |
});
|
| 169 |
-
let
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
clusterNames.push(name.length > 0 ? name : `Cluster ${c + 1}`);
|
| 171 |
}
|
| 172 |
// After all names are generated, update the trace names and render once
|
|
|
|
| 166 |
do_sample: false,
|
| 167 |
streamer,
|
| 168 |
});
|
| 169 |
+
let rawName = tokenizer.decode(outputTokens[0], { skip_special_tokens: false }).trim();
|
| 170 |
+
// Extract cluster name after last '</think>' if present, and remove '<|im_end|>' if present
|
| 171 |
+
let idx = rawName.lastIndexOf('</think>');
|
| 172 |
+
let name = idx !== -1 ? rawName.slice(idx + 8).trim() : rawName;
|
| 173 |
+
if (name.endsWith('<|im_end|>')) name = name.slice(0, -11).trim();
|
| 174 |
clusterNames.push(name.length > 0 ? name : `Cluster ${c + 1}`);
|
| 175 |
}
|
| 176 |
// After all names are generated, update the trace names and render once
|