ping98k commited on
Commit
87be6a3
·
1 Parent(s): ef7c02e

Add prompt cluster logic for summarizing multiple sentences into concise phrases

Browse files
Files changed (2) hide show
  1. main.js +5 -3
  2. prompt_cluster.js +32 -0
main.js CHANGED
@@ -1,6 +1,6 @@
1
  import { pipeline, TextStreamer, AutoTokenizer, AutoModelForCausalLM } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.6.0';
2
  import { UMAP } from "https://cdn.jsdelivr.net/npm/umap-js@1.4.0/+esm";
3
-
4
  const embed = await pipeline(
5
  "feature-extraction",
6
  "onnx-community/Qwen3-Embedding-0.6B-ONNX",
@@ -121,8 +121,10 @@ document.getElementById("kmeans-btn").onclick = async () => {
121
  progressBarInner.style.width = `${Math.round(((c) / k) * 100)}%`;
122
  const joined = clustered[c].join("\n");
123
  const messages = [
124
- { role: "system", content: "Given the following texts, provide a short 1-3 word summary in plaintext" },
125
- { role: "user", content: `${joined}` }
 
 
126
  ];
127
 
128
  const inputs = tokenizer.apply_chat_template(messages, {
 
1
  import { pipeline, TextStreamer, AutoTokenizer, AutoModelForCausalLM } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.6.0';
2
  import { UMAP } from "https://cdn.jsdelivr.net/npm/umap-js@1.4.0/+esm";
3
+ import { prompt_cluster } from "./prompt_cluster.js"
4
  const embed = await pipeline(
5
  "feature-extraction",
6
  "onnx-community/Qwen3-Embedding-0.6B-ONNX",
 
121
  progressBarInner.style.width = `${Math.round(((c) / k) * 100)}%`;
122
  const joined = clustered[c].join("\n");
123
  const messages = [
124
+ {
125
+ role: "system", content: prompt_cluster
126
+ },
127
+ { role: "user", content: `Input:\n${joined}\nOutput:` }
128
  ];
129
 
130
  const inputs = tokenizer.apply_chat_template(messages, {
prompt_cluster.js ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export const prompt_cluster = `Given the following texts, Summarize multiple sentences into a single 1-3 word phrase plain text.
2
+
3
+ Example 1
4
+ Input:
5
+ The new smartphone features a foldable display and 5G connectivity.
6
+ Virtual reality headsets are becoming more affordable and accessible.
7
+ Output: Next Generation Devices
8
+
9
+ Example 2
10
+ Input:
11
+ Athletes are breaking records in international competitions.
12
+ Sports streaming is reaching global audiences in real time.
13
+ Output: Global Competitive Sports
14
+
15
+ Example 3
16
+ Input:
17
+ In the world of AI, transformers have revolutionized natural language processing.
18
+ Quantum computing promises to solve problems beyond classical computers' reach.
19
+ Output: Intelligent Computational Systems
20
+
21
+ Example 4
22
+ Input:
23
+ Blockchain technology is being explored for secure voting systems.
24
+ Quantum computing promises to solve problems beyond classical computers' reach.
25
+ In the world of AI, transformers have revolutionized natural language processing.
26
+ Output: Emerging Digital Technologies
27
+
28
+ Example 5
29
+ Input:
30
+ Homemade meals are becoming more popular due to health consciousness.
31
+ Cooking tutorials are widely available on social media platforms.
32
+ Output: Modern Home Cooking`