Spaces:
Running on Zero
Running on Zero
Fix dark dropdown readability and explain all connection modes
Browse files- style.css +12 -0
- token_space.js +47 -1
style.css
CHANGED
|
@@ -156,3 +156,15 @@ header p { font: 18px/1.6 Georgia, serif; color: #777; }
|
|
| 156 |
.space-tools [data-space-step],.space-empty small { color:#b8cbd1 !important; }
|
| 157 |
.space-top .space-count { color:#8aa4ad !important; }
|
| 158 |
.space-top .space-brand { color:#f4bf67 !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
.space-tools [data-space-step],.space-empty small { color:#b8cbd1 !important; }
|
| 157 |
.space-top .space-count { color:#8aa4ad !important; }
|
| 158 |
.space-top .space-brand { color:#f4bf67 !important; }
|
| 159 |
+
|
| 160 |
+
/* Keep native popup options and explanatory text readable on the dark canvas. */
|
| 161 |
+
#token-universe select,#token-universe select option { color:#f4f7f8 !important; background-color:#112530 !important; color-scheme:dark; opacity:1 !important; }
|
| 162 |
+
.space-tools label,.layer-controls label,.layer-controls label > span,.layer-caption,.layer-caption span,.attention-intro,.attention-meta,.attention-coverage,.attention-help p { color:#eef3f5 !important; }
|
| 163 |
+
.connection-explanation,.connection-note,.connection-selected,.connection-token { color:#eef3f5 !important; }
|
| 164 |
+
.connection-explanation { margin:8px 0 12px; font:14px/1.6 system-ui,sans-serif; }
|
| 165 |
+
.connection-note { margin:10px 0; font:13px/1.6 system-ui,sans-serif; }
|
| 166 |
+
.connection-selected { margin:16px 0 10px; font:600 13px/1.5 system-ui,sans-serif; overflow-wrap:anywhere; }
|
| 167 |
+
.connection-matches { display:grid; gap:9px; margin:12px 0; }
|
| 168 |
+
.connection-match { display:flex; justify-content:space-between; align-items:baseline; gap:12px; }
|
| 169 |
+
.connection-token { min-width:0; overflow-wrap:anywhere; font:13px/1.5 ui-monospace,monospace; }
|
| 170 |
+
.connection-score { color:#f4bf67 !important; flex-shrink:0; font:12px/1.5 ui-monospace,monospace; }
|
token_space.js
CHANGED
|
@@ -143,7 +143,53 @@
|
|
| 143 |
function details(){
|
| 144 |
const box=root?.querySelector('.space-detail');if(!box)return;
|
| 145 |
const point=history.find(p=>p.n===selected)||externalSelected||(connections==='attention'?sourcePoint():null);
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
if(point){
|
| 148 |
const neighbours=(point.links||[]).map(link=>{
|
| 149 |
const other=history.find(p=>p.n===link.n);
|
|
|
|
| 143 |
function details(){
|
| 144 |
const box=root?.querySelector('.space-detail');if(!box)return;
|
| 145 |
const point=history.find(p=>p.n===selected)||externalSelected||(connections==='attention'?sourcePoint():null);
|
| 146 |
+
if(connections!=='attention'){
|
| 147 |
+
const signature=JSON.stringify([connections,point?.n,point?.label,point?.links]);
|
| 148 |
+
if(box.dataset.connectionSignature===signature)return;
|
| 149 |
+
delete box.dataset.attentionSignature;box.dataset.connectionSignature=signature;
|
| 150 |
+
box.replaceChildren();
|
| 151 |
+
function add(parent,tag,className,text){
|
| 152 |
+
const node=document.createElement(tag);node.className=className;
|
| 153 |
+
if(text!=null)node.textContent=text;parent.appendChild(node);return node;
|
| 154 |
+
}
|
| 155 |
+
const titles={order:'Generation order',similarity:'Embedding similarity',none:'Tokens only'};
|
| 156 |
+
add(box,'h3','attention-title',titles[connections]||'Connections');
|
| 157 |
+
if(connections==='order'){
|
| 158 |
+
add(box,'p','connection-explanation','Teal lines connect consecutive tokens in the order they were generated. Follow them to trace the stream through the 3D space.');
|
| 159 |
+
add(box,'p','connection-note','These lines show sequence, not attention, similarity, or how strongly one token influenced another.');
|
| 160 |
+
if(point){
|
| 161 |
+
add(box,'p','connection-selected',`Selected: #${point.n+1} ${JSON.stringify(point.label)} / token ID ${point.id}`);
|
| 162 |
+
const previous=contextPoint(point.n-1);
|
| 163 |
+
add(box,'p','connection-note',point.n===0?'This is the first generated token.':`Previous token: #${point.n}${previous?' '+JSON.stringify(previous.label):''}. A line appears when both tokens are visible.`);
|
| 164 |
+
}else add(box,'p','connection-note','Click a token to see its place in the sequence. Faded tokens can leave gaps; use History or pause to inspect earlier tokens.');
|
| 165 |
+
}else if(connections==='similarity'){
|
| 166 |
+
add(box,'p','connection-explanation','Amber lines connect each token to up to three earlier tokens with the most similar learned input embeddings.');
|
| 167 |
+
add(box,'p','connection-note','The matches are calculated from the original embedding vectors, not the distances you see in 3D.');
|
| 168 |
+
if(point){
|
| 169 |
+
add(box,'p','connection-selected',`Selected: #${point.n+1} ${JSON.stringify(point.label)} / token ID ${point.id}`);
|
| 170 |
+
const matches=(point.links||[]).map(link=>({...link,other:contextPoint(link.n)}));
|
| 171 |
+
if(matches.length){
|
| 172 |
+
add(box,'p','connection-note','Closest saved earlier matches:');
|
| 173 |
+
const list=add(box,'div','connection-matches');
|
| 174 |
+
for(const link of matches){
|
| 175 |
+
const item=add(list,'div','connection-match');
|
| 176 |
+
add(item,'span','connection-token',`${link.other?JSON.stringify(link.other.label):'Token'} (#${link.n+1})`);
|
| 177 |
+
add(item,'span','connection-score',`cosine ${link.score.toFixed(3)}`);
|
| 178 |
+
}
|
| 179 |
+
}else add(box,'p','connection-note','No saved similarity matches for this token in the retained history.');
|
| 180 |
+
}else add(box,'p','connection-note','Click a token to see its closest saved matches and their similarity scores.');
|
| 181 |
+
const help=add(box,'details','attention-help');
|
| 182 |
+
add(help,'summary','','How to read similarity');
|
| 183 |
+
add(help,'p','','Cosine similarity compares the direction of embedding vectors. Higher scores mean more aligned vectors; only positive matches are drawn. The score is not a probability or an attention weight. We compare distinct token IDs within the preceding 512 tokens. Compressing embeddings to three dimensions can distort apparent distances.');
|
| 184 |
+
}else{
|
| 185 |
+
add(box,'p','connection-explanation','No connection lines are drawn. Token positions still come from the fixed 3D projection of their input embeddings.');
|
| 186 |
+
add(box,'p','connection-note','Use this view to explore the token cloud without lines. Changing connection modes only changes the visualisation; it does not change how text is generated.');
|
| 187 |
+
if(point)add(box,'p','connection-selected',`Selected: #${point.n+1} ${JSON.stringify(point.label)} / token ID ${point.id}`);
|
| 188 |
+
}
|
| 189 |
+
return;
|
| 190 |
+
}
|
| 191 |
+
delete box.dataset.connectionSignature;
|
| 192 |
+
let content='Attention weights show which context tokens each layer attended to while predicting the following token. Generate text, then pause and click a token to compare saved layers.';
|
| 193 |
if(point){
|
| 194 |
const neighbours=(point.links||[]).map(link=>{
|
| 195 |
const other=history.find(p=>p.n===link.n);
|