jejunepixels commited on
Commit
a02fde5
·
verified ·
1 Parent(s): 17374eb

Select paused text tokens to focus their 3D positions and attention

Browse files
Files changed (6) hide show
  1. README.md +17 -1
  2. app.py +1 -0
  3. engine.py +1 -0
  4. style.css +10 -0
  5. token_space.js +78 -15
  6. token_space.py +36 -1
README.md CHANGED
@@ -107,11 +107,27 @@ long memory. Capture may be disabled. Unsupported custom attention architectures
107
  can generate with capture disabled. Attention weights describe one operation in the
108
  network and are not a complete causal explanation or access to private reasoning.
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  ## Pause and token stepping
111
 
112
  Pause generation finishes the current inference step and stops sampling. It switches
113
  the viewer to a non-fading attention inspection mode. Step back and Step forward
114
- move through the retained history (up to the last 512 token occurrences). The
115
  view hides future tokens relative to the selected query and shows that query's
116
  recorded attention, including faint older targets. Rows that were not captured
117
  are labelled as unavailable; the final token has no row until it predicts another.
 
107
  can generate with capture disabled. Attention weights describe one operation in the
108
  network and are not a complete causal explanation or access to private reasoning.
109
 
110
+ ## Clickable paused text
111
+
112
+ While generation is paused, the top text overlay becomes a token-aware reader.
113
+ Click a token occurrence to highlight it in the text, focus its position in 3D,
114
+ and show its captured attention. Step back and Step forward stay synchronized with
115
+ the text highlight. Resume restores the normal full-text overlay. Repeated token
116
+ IDs remain separate occurrences. All generated tokens can be located in 3D from
117
+ the text; only the last 512 token occurrences retain attention rows.
118
+
119
+ The reader uses the tokenizer's streaming decoder to preserve the exact text.
120
+ When several byte-level tokens jointly produce one Unicode character, clicking
121
+ that text exposes individual token choices. For unsupported streaming decoders,
122
+ the exact prose is retained with selectable token pieces below it. Model text is
123
+ inserted using textContent, not interpreted as HTML. Clickable text does not change
124
+ sampling, token IDs, the generated passage, or RNG state.
125
+
126
  ## Pause and token stepping
127
 
128
  Pause generation finishes the current inference step and stops sampling. It switches
129
  the viewer to a non-fading attention inspection mode. Step back and Step forward
130
+ move through generated token occurrences. Only the last 512 occurrences retain attention; older tokens can still be located by their embeddings. The
131
  view hides future tokens relative to the selected query and shows that query's
132
  recorded attention, including faint older targets. Rows that were not captured
133
  are labelled as unavailable; the final token has no row until it predicts another.
app.py CHANGED
@@ -43,6 +43,7 @@ def clear(flow):
43
  flow.tokens.clear()
44
  flow.space_history.clear()
45
  flow.attention_history.clear()
 
46
  flow.paused = False
47
  flow.text = ""
48
  flow.model_key = ""
 
43
  flow.tokens.clear()
44
  flow.space_history.clear()
45
  flow.attention_history.clear()
46
+ flow.text_snapshot_cache = None
47
  flow.paused = False
48
  flow.text = ""
49
  flow.model_key = ""
engine.py CHANGED
@@ -15,6 +15,7 @@ class Flow:
15
  self.attention_history = {}
16
  self.paused = False
17
  self.view_lock = threading.RLock()
 
18
  self.text = text
19
  self.model_key = model_key
20
  self.seed = seed
 
15
  self.attention_history = {}
16
  self.paused = False
17
  self.view_lock = threading.RLock()
18
+ self.text_snapshot_cache = None
19
  self.text = text
20
  self.model_key = model_key
21
  self.seed = seed
style.css CHANGED
@@ -59,3 +59,13 @@ header p { font: 18px/1.6 Georgia, serif; color: #777; }
59
  #token-universe { position:fixed !important; inset:0 !important; width:100vw !important; height:100dvh !important; }
60
  #stream-buttons { position:sticky; top:0; z-index:6; background:#eaf2eff2; }
61
  #control-dock { --body-text-color:#203c3a; --body-text-color-subdued:#526b68; --input-text-color:#1c3536; --input-background-fill:#fff; --block-background-fill:#f4f8f6; --block-label-text-color:#29433f; --block-info-text-color:#526b68; color:#203c3a; }
 
 
 
 
 
 
 
 
 
 
 
59
  #token-universe { position:fixed !important; inset:0 !important; width:100vw !important; height:100dvh !important; }
60
  #stream-buttons { position:sticky; top:0; z-index:6; background:#eaf2eff2; }
61
  #control-dock { --body-text-color:#203c3a; --body-text-color-subdued:#526b68; --input-text-color:#1c3536; --input-background-fill:#fff; --block-background-fill:#f4f8f6; --block-label-text-color:#29433f; --block-info-text-color:#526b68; color:#203c3a; }
62
+ #page[data-token-inspection="true"] textarea { display:none !important; }
63
+ .paused-token-reader { position:relative; height:clamp(110px,22vh,240px); max-height:45vh; overflow-y:auto; padding:14px 24px 20px; color:#e0eeeb; font:clamp(16px,1.5vw,21px)/1.7 Georgia,serif; scrollbar-color:#668c8b #10232d; }
64
+ .token-reader-hint { position:sticky; top:-14px; padding:6px 0 10px; background:#0c1c27f5; color:#93c9be; font:11px/1.4 system-ui,sans-serif; letter-spacing:.04em; z-index:1; }
65
+ .paused-token-content { white-space:pre-wrap; overflow-wrap:anywhere; }
66
+ .paused-token-reader button.text-token { all:unset; display:inline; white-space:pre-wrap; font:inherit; color:inherit; cursor:pointer; border-radius:4px; }
67
+ .paused-token-reader button.text-token:hover { background:#ffffff20; box-shadow:0 0 0 1px #8fd7c466; }
68
+ .paused-token-reader button.text-token.is-selected { background:#eabe73; color:#17242b; box-shadow:0 0 0 2px #eabe7355; }
69
+ .paused-token-reader button.text-token:focus-visible { outline:2px solid #9ce4d2; outline-offset:2px; }
70
+ .token-piece-choices { margin-top:8px; color:#b4cdd2; font:12px/1.7 ui-monospace,monospace; }
71
+ @media(max-width:640px){.paused-token-reader { height:20vh;padding:12px 16px;font-size:16px; }}
token_space.js CHANGED
@@ -7,20 +7,79 @@
7
  const lifetime=6000;
8
  let lastText='';
9
  let paused=false, previousMode='live';
 
10
  function sourcePoint(){
11
- const pinned=history.find(p=>p.n===selected);
12
  if(paused)return pinned;
13
  if(pinned?.attention&&(mode==='history'||Date.now()-Math.max(pinned.born,pinned.attentionBorn??0)<lifetime))return pinned;
14
  return [...history].reverse().find(p=>p.attention&&(mode==='history'||Date.now()-Math.max(p.born,p.attentionBorn??0)<lifetime));
15
  }
16
- function stepToken(direction){
17
- if(!paused||!history.length)return;
18
- let index=history.findIndex(p=>p.n===selected);
19
- if(index<0)index=history.length-1;
20
- index=Math.max(0,Math.min(history.length-1,index+direction));
21
- selected=history[index].n;connections='attention';
22
  const input=root.querySelector('[data-space-links]');if(input)input.value=connections;
23
- details();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
  function resetCamera(){yaw=.35;pitch=-.15;zoom=1;target=[0,0,0];panX=panY=0;}
26
  function pick(e){
@@ -29,7 +88,7 @@
29
  }
30
  function details(){
31
  const box=root?.querySelector('.space-detail');if(!box)return;
32
- const point=history.find(p=>p.n===selected)||(connections==='attention'?sourcePoint():null);
33
  let content='Click a token to inspect its earlier neighbours.';
34
  if(point){
35
  const neighbours=(point.links||[]).map(link=>{
@@ -46,7 +105,7 @@
46
  return `${link.n===-1?'[boundary token]':other?JSON.stringify(other.label):link.label?JSON.stringify(link.label):'#'+(link.n+1)}: ${(100*link.score).toFixed(1)}%`;
47
  });
48
  content=`Attention from #${point.n+1} ${JSON.stringify(point.label)}, layer ${row.layer}, ${row.head===-1?'mean across heads':'head '+row.head}, while predicting the following token. ${targets.join('; ')}. Top-8 mass: ${(100*row.shown_mass).toFixed(1)}%.`;
49
- }else content='No attention captured for this token yet. Enable Capture attention and generate more tokens.';
50
  }
51
  if(box.textContent!==content)box.textContent=content;
52
  }
@@ -90,7 +149,7 @@
90
  mount();const node=document.querySelector('[data-flow-frame]');if(!node)return;
91
  const raw=node.getAttribute('data-flow-frame');if(raw===payload)return;
92
  payload=raw;let data;try{data=JSON.parse(raw);}catch{return;}
93
- if(data.stream!==stream){stream=data.stream;seen=-1;history=[];selected=null;paused=false;details();}
94
  const now=Date.now(),existing=new Set(history.map(p=>p.n));
95
  for(const p of data.points||[]){
96
  if(existing.has(p.n)){const old=history.find(q=>q.n===p.n);if(p.attention){if(!old.attention)old.attentionBorn=now;old.attention=p.attention;}continue;}
@@ -98,16 +157,17 @@
98
  // Recovered old history must not reappear as freshly generated live points.
99
  history.push({...p,born:p.n<=seen?now-lifetime:now,attentionBorn:p.attention?now:0});seen=Math.max(seen,p.n);
100
  }
 
101
  history.sort((a,b)=>a.n-b.n);history=history.slice(-512);
102
  if(Boolean(data.paused)!==paused){
103
  paused=Boolean(data.paused);
104
  if(paused){previousMode=mode;mode='history';selected=[...history].reverse().find(p=>p.attention)?.n??history.at(-1)?.n??null;connections='attention';}
105
- else{mode=previousMode;selected=null;}
106
  const modeInput=root.querySelector('[data-space-mode]');if(modeInput)modeInput.value=mode;
107
  const linksInput=root.querySelector('[data-space-links]');if(linksInput)linksInput.value=connections;
108
  }
109
  if(!paused&&mode==='live'&&selected!=null&&!history.some(p=>p.n===selected&&now-p.born<lifetime))selected=null;
110
- details();
111
  }
112
  function project(v){
113
  const[x,y,z]=v.map((a,i)=>a-target[i]),cy=Math.cos(yaw),sy=Math.sin(yaw),rx=x*cy+z*sy,rz=-x*sy+z*cy;
@@ -132,6 +192,7 @@
132
  const cutoff=paused&&selected!=null?selected:Infinity;
133
  const source=connections==='attention'?sourcePoint():null;
134
  const active=history.filter(p=>p.n<=cutoff&&(mode==='history'||paused||p.n===source?.n||now-p.born<lifetime));
 
135
  const activeIndices=new Set(active.map(p=>p.n));
136
  if(source?.attention){
137
  for(const link of source.attention.links){
@@ -183,10 +244,12 @@
183
  if(counter&&counter.textContent!==count)counter.textContent=count;
184
  if(empty){const display=seen<0?'flex':'none';if(empty.style.display!==display)empty.style.display=display;}
185
  const back=root.querySelector('[data-space-back]'),forward=root.querySelector('[data-space-forward]'),step=root.querySelector('[data-space-step]');
186
- if(back)back.disabled=!paused||selected==null||selected<=history[0]?.n;
187
- if(forward)forward.disabled=!paused||selected==null||selected>=history.at(-1)?.n;
 
188
  const stepText=paused?`Paused ? inspecting token #${selected==null?'?':selected+1}`:'Live';
189
  if(step&&step.textContent!==stepText)step.textContent=stepText;
 
190
  const text=document.querySelector('#page textarea');
191
  if(text&&text.value!==lastText){
192
  const following=lastText===''||text.scrollHeight-text.scrollTop-text.clientHeight<80;
 
7
  const lifetime=6000;
8
  let lastText='';
9
  let paused=false, previousMode='live';
10
+ let textView=null,externalSelected=null,reader=null,readerSignature='',lastHighlighted=null;
11
  function sourcePoint(){
12
+ const pinned=history.find(p=>p.n===selected)||externalSelected;
13
  if(paused)return pinned;
14
  if(pinned?.attention&&(mode==='history'||Date.now()-Math.max(pinned.born,pinned.attentionBorn??0)<lifetime))return pinned;
15
  return [...history].reverse().find(p=>p.attention&&(mode==='history'||Date.now()-Math.max(p.born,p.attentionBorn??0)<lifetime));
16
  }
17
+ function chooseToken(index,focus=true){
18
+ if(!paused)return;
19
+ const point=history.find(p=>p.n===index)||textView?.points.find(p=>p.n===index);
20
+ if(!point)return;
21
+ selected=index;externalSelected=history.some(p=>p.n===index)?null:point;connections='attention';
 
22
  const input=root.querySelector('[data-space-links]');if(input)input.value=connections;
23
+ if(focus){target=[...point.xyz];panX=panY=0;zoom=Math.min(3,Math.max(1,zoom));}
24
+ details();syncTextSelection();
25
+ }
26
+ function stepToken(direction){
27
+ const items=textView?.points||history;
28
+ if(!paused||!items.length)return;
29
+ let index=items.findIndex(p=>p.n===selected);
30
+ if(index<0)index=items.length-1;
31
+ index=Math.max(0,Math.min(items.length-1,index+direction));
32
+ chooseToken(items[index].n);
33
+ }
34
+ function syncTextSelection(){
35
+ if(!reader||lastHighlighted===selected)return;
36
+ lastHighlighted=selected;let first=null;
37
+ for(const button of reader.querySelectorAll('[data-flow-indices]')){
38
+ const on=button.dataset.flowIndices.split(',').map(Number).includes(selected);
39
+ button.classList.toggle('is-selected',on);
40
+ button.setAttribute('aria-pressed',String(on));
41
+ if(on&&!first)first=button;
42
+ }
43
+ first?.scrollIntoView({block:'nearest',inline:'nearest'});
44
+ }
45
+ function inspectText(){
46
+ const host=document.querySelector('#page');if(!host)return;
47
+ if(!paused||!textView){
48
+ host.querySelector('[data-token-reader]')?.remove();host.removeAttribute('data-token-inspection');
49
+ reader=null;readerSignature='';lastHighlighted=null;return;
50
+ }
51
+ const signature=`${stream}:${textView.points.length}:${textView.segments.length}`;
52
+ if(readerSignature===signature&&host.querySelector('[data-token-reader]')===reader){syncTextSelection();return;}
53
+ host.querySelector('[data-token-reader]')?.remove();
54
+ reader=document.createElement('div');reader.setAttribute('data-token-reader','');reader.className='paused-token-reader';
55
+ const hint=document.createElement('div');hint.className='token-reader-hint';hint.textContent='PAUSED / Click a token to locate it and inspect its attention.';
56
+ const content=document.createElement('div');content.className='paused-token-content';
57
+ const choices=document.createElement('div');choices.className='token-piece-choices';
58
+ function button(indices,label){
59
+ const node=document.createElement('button');node.type='button';node.textContent=label;
60
+ node.dataset.flowIndices=indices.join(',');node.className='text-token';
61
+ node.title=indices.map(n=>{const p=textView.points[n];return `Token #${n+1} / ID ${p.id}`;}).join(' / ');
62
+ node.addEventListener('click',()=>{
63
+ if(!paused||!textView)return;
64
+ chooseToken(indices.at(-1));choices.replaceChildren();
65
+ if(indices.length>1){
66
+ const label=document.createElement('span');label.textContent='This text shares multiple tokens: ';choices.appendChild(label);
67
+ for(const n of indices){const point=textView.points[n];choices.appendChild(button([n],`#${n+1} ${JSON.stringify(point.label)} `));}
68
+ }
69
+ lastHighlighted=null;syncTextSelection();
70
+ });return node;
71
+ }
72
+ if(textView.segments.length){
73
+ for(const segment of textView.segments){
74
+ content.appendChild(segment.indices.length?button(segment.indices,segment.text):document.createTextNode(segment.text));
75
+ }
76
+ }else{
77
+ const prose=document.createElement('div');prose.textContent=textView.text;content.appendChild(prose);
78
+ hint.textContent='PAUSED / Select a token piece below to inspect it in 3D.';
79
+ for(const point of textView.points)content.appendChild(button([point.n],JSON.stringify(point.label)+' '));
80
+ }
81
+ reader.appendChild(hint);reader.appendChild(content);reader.appendChild(choices);host.appendChild(reader);
82
+ host.setAttribute('data-token-inspection','true');readerSignature=signature;lastHighlighted=null;syncTextSelection();
83
  }
84
  function resetCamera(){yaw=.35;pitch=-.15;zoom=1;target=[0,0,0];panX=panY=0;}
85
  function pick(e){
 
88
  }
89
  function details(){
90
  const box=root?.querySelector('.space-detail');if(!box)return;
91
+ const point=history.find(p=>p.n===selected)||externalSelected||(connections==='attention'?sourcePoint():null);
92
  let content='Click a token to inspect its earlier neighbours.';
93
  if(point){
94
  const neighbours=(point.links||[]).map(link=>{
 
105
  return `${link.n===-1?'[boundary token]':other?JSON.stringify(other.label):link.label?JSON.stringify(link.label):'#'+(link.n+1)}: ${(100*link.score).toFixed(1)}%`;
106
  });
107
  content=`Attention from #${point.n+1} ${JSON.stringify(point.label)}, layer ${row.layer}, ${row.head===-1?'mean across heads':'head '+row.head}, while predicting the following token. ${targets.join('; ')}. Top-8 mass: ${(100*row.shown_mass).toFixed(1)}%.`;
108
+ }else content=externalSelected?'This token is outside the retained 512-token attention history. Its embedding is shown; no saved attention row is available.':'No attention captured for this token yet. Enable Capture attention and generate more tokens.';
109
  }
110
  if(box.textContent!==content)box.textContent=content;
111
  }
 
149
  mount();const node=document.querySelector('[data-flow-frame]');if(!node)return;
150
  const raw=node.getAttribute('data-flow-frame');if(raw===payload)return;
151
  payload=raw;let data;try{data=JSON.parse(raw);}catch{return;}
152
+ if(data.stream!==stream){stream=data.stream;seen=-1;history=[];selected=null;paused=false;textView=null;externalSelected=null;details();}
153
  const now=Date.now(),existing=new Set(history.map(p=>p.n));
154
  for(const p of data.points||[]){
155
  if(existing.has(p.n)){const old=history.find(q=>q.n===p.n);if(p.attention){if(!old.attention)old.attentionBorn=now;old.attention=p.attention;}continue;}
 
157
  // Recovered old history must not reappear as freshly generated live points.
158
  history.push({...p,born:p.n<=seen?now-lifetime:now,attentionBorn:p.attention?now:0});seen=Math.max(seen,p.n);
159
  }
160
+ if(data.text_view)textView=data.text_view;
161
  history.sort((a,b)=>a.n-b.n);history=history.slice(-512);
162
  if(Boolean(data.paused)!==paused){
163
  paused=Boolean(data.paused);
164
  if(paused){previousMode=mode;mode='history';selected=[...history].reverse().find(p=>p.attention)?.n??history.at(-1)?.n??null;connections='attention';}
165
+ else{mode=previousMode;selected=null;externalSelected=null;textView=null;}
166
  const modeInput=root.querySelector('[data-space-mode]');if(modeInput)modeInput.value=mode;
167
  const linksInput=root.querySelector('[data-space-links]');if(linksInput)linksInput.value=connections;
168
  }
169
  if(!paused&&mode==='live'&&selected!=null&&!history.some(p=>p.n===selected&&now-p.born<lifetime))selected=null;
170
+ details();inspectText();
171
  }
172
  function project(v){
173
  const[x,y,z]=v.map((a,i)=>a-target[i]),cy=Math.cos(yaw),sy=Math.sin(yaw),rx=x*cy+z*sy,rz=-x*sy+z*cy;
 
192
  const cutoff=paused&&selected!=null?selected:Infinity;
193
  const source=connections==='attention'?sourcePoint():null;
194
  const active=history.filter(p=>p.n<=cutoff&&(mode==='history'||paused||p.n===source?.n||now-p.born<lifetime));
195
+ if(paused&&externalSelected)active.push({...externalSelected,born:now});
196
  const activeIndices=new Set(active.map(p=>p.n));
197
  if(source?.attention){
198
  for(const link of source.attention.links){
 
244
  if(counter&&counter.textContent!==count)counter.textContent=count;
245
  if(empty){const display=seen<0?'flex':'none';if(empty.style.display!==display)empty.style.display=display;}
246
  const back=root.querySelector('[data-space-back]'),forward=root.querySelector('[data-space-forward]'),step=root.querySelector('[data-space-step]');
247
+ const items=textView?.points||history;
248
+ if(back)back.disabled=!paused||selected==null||selected<=items[0]?.n;
249
+ if(forward)forward.disabled=!paused||selected==null||selected>=items.at(-1)?.n;
250
  const stepText=paused?`Paused ? inspecting token #${selected==null?'?':selected+1}`:'Live';
251
  if(step&&step.textContent!==stepText)step.textContent=stepText;
252
+ inspectText();syncTextSelection();
253
  const text=document.querySelector('#page textarea');
254
  if(text&&text.value!==lastText){
255
  const following=lastText===''||text.scrollHeight-text.scrollTop-text.clientHeight<80;
token_space.py CHANGED
@@ -5,6 +5,36 @@ import json
5
  import torch
6
 
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  class TokenProjection:
9
  def __init__(self, weights):
10
  weights = weights.detach().float().cpu()
@@ -70,7 +100,12 @@ def _frame(flow, store, full=False):
70
  store.tokenizer.decode([link["id"]], skip_special_tokens=False,
71
  clean_up_tokenization_spaces=False))
72
  points = flow.space_history[-512 if full else -48:]
73
- payload = json.dumps({"stream": flow.stream_id, "paused": flow.paused, "points": points}, ensure_ascii=True)
 
 
 
 
 
74
  return '<div data-flow-frame="' + html.escape(payload, quote=True) + '"></div>'
75
 
76
 
 
5
  import torch
6
 
7
 
8
+ def text_snapshot(tokens, tokenizer, projection):
9
+ """Map displayed text back to actual token occurrences, including byte fragments."""
10
+ from tokenizers.decoders import DecodeStream
11
+ text = tokenizer.decode(tokens, skip_special_tokens=True, clean_up_tokenization_spaces=False)
12
+ points = [{"n": n, "id": token_id, "xyz": projection.point(token_id),
13
+ "label": tokenizer.decode([token_id], skip_special_tokens=False,
14
+ clean_up_tokenization_spaces=False)}
15
+ for n, token_id in enumerate(tokens)]
16
+ segments, pending, decoded = [], [], ""
17
+ try:
18
+ decoder = DecodeStream(skip_special_tokens=True)
19
+ special = set(tokenizer.all_special_ids)
20
+ for n, token_id in enumerate(tokens):
21
+ if token_id not in special:
22
+ pending.append(n)
23
+ chunk = decoder.step(tokenizer.backend_tokenizer, token_id)
24
+ if chunk:
25
+ segments.append({"text": chunk, "indices": pending})
26
+ pending = []
27
+ decoded += chunk
28
+ if text.startswith(decoded) and decoded != text:
29
+ segments.append({"text": text[len(decoded):], "indices": pending})
30
+ decoded = text
31
+ if decoded != text:
32
+ segments = []
33
+ except (AttributeError, TypeError, ValueError):
34
+ segments = []
35
+ return {"text": text, "segments": segments, "points": points}
36
+
37
+
38
  class TokenProjection:
39
  def __init__(self, weights):
40
  weights = weights.detach().float().cpu()
 
100
  store.tokenizer.decode([link["id"]], skip_special_tokens=False,
101
  clean_up_tokenization_spaces=False))
102
  points = flow.space_history[-512 if full else -48:]
103
+ data = {"stream": flow.stream_id, "paused": flow.paused, "points": points}
104
+ if flow.paused and store.projection is not None and flow.model_key == store.key:
105
+ if flow.text_snapshot_cache is None or flow.text_snapshot_cache[0] != len(tokens):
106
+ flow.text_snapshot_cache = (len(tokens), text_snapshot(tokens, store.tokenizer, store.projection))
107
+ data["text_view"] = flow.text_snapshot_cache[1]
108
+ payload = json.dumps(data, ensure_ascii=True)
109
  return '<div data-flow-frame="' + html.escape(payload, quote=True) + '"></div>'
110
 
111