Spaces:
Running on Zero
Running on Zero
Rename to Automatic Token Generation with amber accents and Surrealist introduction
Browse files- README.md +2 -2
- app.py +10 -5
- style.css +23 -13
- token_space.js +2 -2
- token_space.py +1 -1
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: 🌊
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: gray
|
|
@@ -11,7 +11,7 @@ python_version: '3.12'
|
|
| 11 |
hf_oauth: true
|
| 12 |
---
|
| 13 |
|
| 14 |
-
#
|
| 15 |
|
| 16 |
A prompt-free automatic-writing experiment. Load a public Hugging Face base model,
|
| 17 |
press **Begin**, and watch it generate from a special beginning token alone. No
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Automatic Token Generation
|
| 3 |
emoji: 🌊
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: gray
|
|
|
|
| 11 |
hf_oauth: true
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# Automatic Token Generation
|
| 15 |
|
| 16 |
A prompt-free automatic-writing experiment. Load a public Hugging Face base model,
|
| 17 |
press **Begin**, and watch it generate from a special beginning token alone. No
|
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
"""
|
| 2 |
from gpu_runtime import ZERO_GPU, spaces
|
| 3 |
import html
|
| 4 |
import secrets
|
|
@@ -240,12 +240,17 @@ def refresh_view(flow):
|
|
| 240 |
def build_app():
|
| 241 |
css = Path(__file__).with_name("style.css").read_text(encoding="utf-8")
|
| 242 |
js = Path(__file__).with_name("token_space.js").read_text(encoding="utf-8")
|
| 243 |
-
with gr.Blocks(title="
|
| 244 |
-
primary_hue="
|
| 245 |
flow = gr.State(Flow())
|
| 246 |
with gr.Column(elem_id="model-picker") as picker:
|
| 247 |
gr.HTML('<header><div class="eyebrow">AN EXPERIMENT IN AUTOMATIC WRITING</div>'
|
| 248 |
-
'<h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
if ZERO_GPU:
|
| 250 |
gr.LoginButton()
|
| 251 |
gr.Markdown("Sign in to use your Hugging Face ZeroGPU quota. Generation uses short GPU sessions; Pause releases the GPU.")
|
|
@@ -254,7 +259,7 @@ def build_app():
|
|
| 254 |
model_note = gr.Textbox(value=MODEL_LABELS[PRESETS[0]], label="Model description", interactive=False)
|
| 255 |
repo.change(lambda value: MODEL_LABELS.get(value, "Custom public model repository or URL"),
|
| 256 |
[repo], model_note, queue=False, api_name="model_description")
|
| 257 |
-
load = gr.Button("Load model & enter space", variant="primary")
|
| 258 |
gr.Markdown("Small **base models** work best. Public safetensors models only; " +
|
| 259 |
("Preloaded models up to 8 GB; each visitor has a separate stream. " if ZERO_GPU else "2 GB download limit. One model is shared by visitors. ") +
|
| 260 |
"Loading includes preparing a fixed 3D embedding projection.")
|
|
|
|
| 1 |
+
"""Automatic Token Generation — a prompt-free Hugging Face Space."""
|
| 2 |
from gpu_runtime import ZERO_GPU, spaces
|
| 3 |
import html
|
| 4 |
import secrets
|
|
|
|
| 240 |
def build_app():
|
| 241 |
css = Path(__file__).with_name("style.css").read_text(encoding="utf-8")
|
| 242 |
js = Path(__file__).with_name("token_space.js").read_text(encoding="utf-8")
|
| 243 |
+
with gr.Blocks(title="Automatic Token Generation", css=css, js=js, theme=gr.themes.Soft(
|
| 244 |
+
primary_hue="amber", neutral_hue="stone"), delete_cache=(3600, 3600)) as demo:
|
| 245 |
flow = gr.State(Flow())
|
| 246 |
with gr.Column(elem_id="model-picker") as picker:
|
| 247 |
gr.HTML('<header><div class="eyebrow">AN EXPERIMENT IN AUTOMATIC WRITING</div>'
|
| 248 |
+
'<h1>Automatic Token Generation<span class="title-stop">.</span></h1>'
|
| 249 |
+
'<p>Inspired by the Surrealists\u2019 practice of automatic writing, this experiment lets language unfold without a written prompt. '
|
| 250 |
+
'A language model uses recent tokens to predict what could come next, then selects the next token by sampling from those probabilities. '
|
| 251 |
+
'A 3D view tracks attention weights from a selected layer and maps tokens through their embeddings.</p>'
|
| 252 |
+
'<p>The model has no unconscious mind to uncover. This demo offers a look under the hood of how large language models generate text '
|
| 253 |
+
'through learned patterns, attention, and probabilistic sampling within a limited context window.</p></header>')
|
| 254 |
if ZERO_GPU:
|
| 255 |
gr.LoginButton()
|
| 256 |
gr.Markdown("Sign in to use your Hugging Face ZeroGPU quota. Generation uses short GPU sessions; Pause releases the GPU.")
|
|
|
|
| 259 |
model_note = gr.Textbox(value=MODEL_LABELS[PRESETS[0]], label="Model description", interactive=False)
|
| 260 |
repo.change(lambda value: MODEL_LABELS.get(value, "Custom public model repository or URL"),
|
| 261 |
[repo], model_note, queue=False, api_name="model_description")
|
| 262 |
+
load = gr.Button("Load model & enter space", variant="primary", elem_id="load-model")
|
| 263 |
gr.Markdown("Small **base models** work best. Public safetensors models only; " +
|
| 264 |
("Preloaded models up to 8 GB; each visitor has a separate stream. " if ZERO_GPU else "2 GB download limit. One model is shared by visitors. ") +
|
| 265 |
"Loading includes preparing a fixed 3D embedding projection.")
|
style.css
CHANGED
|
@@ -1,20 +1,20 @@
|
|
| 1 |
.gradio-container { max-width: 1600px !important; margin: auto; }
|
| 2 |
header { padding: 36px 8px 28px; }
|
| 3 |
-
.eyebrow { font: 600 11px/1.5 system-ui, sans-serif; letter-spacing: .18em; color: #
|
| 4 |
header h1 { font: 400 clamp(44px, 6vw, 74px)/1.1 Georgia, serif; letter-spacing: -.04em; margin: 12px 0; }
|
| 5 |
-
header h1 span { color: #
|
| 6 |
header p { font: 18px/1.6 Georgia, serif; color: #777; }
|
| 7 |
#page textarea { font: 18px/1.65 Georgia, 'Times New Roman', serif !important; padding: 14px 20px !important; }
|
| 8 |
.inspector { padding: 22px; border: 1px solid #82968b40; border-radius: 14px; min-height: 230px; }
|
| 9 |
.inspector h3 { font: 26px/1.2 Georgia, serif; margin: 12px 0; }
|
| 10 |
.inspector p, .inspector small { opacity: .75; line-height: 1.6; }
|
| 11 |
.candidate { padding: 8px 10px; margin: 6px 0; border-radius: 8px; }
|
| 12 |
-
.candidate.selected { background: #
|
| 13 |
.candidate-label { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
|
| 14 |
.candidate-label code { white-space: pre-wrap; overflow-wrap: anywhere; }
|
| 15 |
.candidate small { font-size: 10px; }
|
| 16 |
.track { height: 5px; background: #82968b20; border-radius: 8px; margin: 7px 0 3px; overflow: hidden; }
|
| 17 |
-
.track div { height: 100%; background: #
|
| 18 |
|
| 19 |
#model-picker { max-width:680px; margin:8vh auto; padding:24px; }
|
| 20 |
#flow-workspace { gap:10px; }
|
|
@@ -27,7 +27,7 @@ header p { font: 18px/1.6 Georgia, serif; color: #777; }
|
|
| 27 |
.space-top,.space-bottom { position:absolute; left:22px; right:22px; display:flex; justify-content:space-between; gap:16px; pointer-events:none; font:11px/1.5 system-ui,sans-serif; }
|
| 28 |
.space-top { top:18px; letter-spacing:.12em; }
|
| 29 |
.space-bottom { bottom:16px; opacity:.6; }
|
| 30 |
-
.space-brand { color:#
|
| 31 |
.space-empty { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; pointer-events:none; font:clamp(20px,3vw,34px)/1.4 Georgia,serif; color:#b9d0d4; }
|
| 32 |
.space-empty small { font:13px/1.5 system-ui,sans-serif; opacity:.65; }
|
| 33 |
.space-transport { display:none !important; }
|
|
@@ -61,21 +61,21 @@ header p { font: 18px/1.6 Georgia, serif; color: #777; }
|
|
| 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:#
|
| 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 #
|
| 68 |
-
.paused-token-reader button.text-token.is-selected { background:#
|
| 69 |
-
.paused-token-reader button.text-token:focus-visible { outline:2px solid #
|
| 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; }}
|
| 72 |
.generation-proxy { display:none !important; }
|
| 73 |
#generation-toggle { border:0 !important; padding:0 !important; background:transparent !important; flex:3 !important; min-width:0 !important; }
|
| 74 |
|
| 75 |
-
.generation-toggle-button { width:100%; min-height:44px; padding:10px 18px; border:0; border-radius:10px; background:#
|
| 76 |
-
.generation-toggle-button:hover { background:#
|
| 77 |
.generation-toggle-button:disabled { opacity:.65; cursor:wait; }
|
| 78 |
-
.generation-toggle-button:focus-visible { outline:3px solid #
|
| 79 |
|
| 80 |
/* Model caption and compact reset remain outside the expandable dock. */
|
| 81 |
#text-overlay { position:absolute !important; top:max(18px,env(safe-area-inset-top)); left:clamp(16px,4vw,72px); right:clamp(16px,4vw,72px); width:auto !important; gap:7px !important; z-index:2; }
|
|
@@ -84,7 +84,7 @@ header p { font: 18px/1.6 Georgia, serif; color: #777; }
|
|
| 84 |
#reset-model { position:absolute !important; right:max(16px,env(safe-area-inset-right)); bottom:max(16px,env(safe-area-inset-bottom)); z-index:8; width:36px !important; height:36px !important; min-width:36px !important; min-height:36px !important; padding:0 !important; border:1px solid #86b6b366 !important; border-radius:50% !important; background:#112530ed !important; color:#c5e2dd !important; font-size:0 !important; box-shadow:0 3px 16px #0004; }
|
| 85 |
#reset-model::before { content:"\21ba"; font:24px/1 system-ui,sans-serif; }
|
| 86 |
#reset-model:hover { background:#23434d !important; color:#fff !important; }
|
| 87 |
-
#reset-model:focus-visible { outline:2px solid #
|
| 88 |
#control-dock { width:min(940px,calc(100vw - 120px)) !important; }
|
| 89 |
@media(max-width:640px) { #text-overlay { top:12px;left:12px;right:12px;gap:5px !important; } #model-name { font-size:12px;padding:0 16px !important; } #control-dock { left:12px;transform:none;width:calc(100vw - 72px) !important; } #reset-model { right:12px;bottom:12px; } }
|
| 90 |
|
|
@@ -95,3 +95,13 @@ header p { font: 18px/1.6 Georgia, serif; color: #777; }
|
|
| 95 |
#page { overflow:hidden !important; background:#091622 !important; background-image:none !important; box-shadow:none !important; }
|
| 96 |
#page > div, #page label, #page .input-container, #page .input-container:focus-within { background:transparent !important; background-image:none !important; border:0 !important; box-shadow:none !important; }
|
| 97 |
#page textarea { background:transparent !important; background-image:none !important; border-radius:0 !important; box-shadow:none !important; resize:none !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
.gradio-container { max-width: 1600px !important; margin: auto; }
|
| 2 |
header { padding: 36px 8px 28px; }
|
| 3 |
+
.eyebrow { font: 600 11px/1.5 system-ui, sans-serif; letter-spacing: .18em; color: #92601c; }
|
| 4 |
header h1 { font: 400 clamp(44px, 6vw, 74px)/1.1 Georgia, serif; letter-spacing: -.04em; margin: 12px 0; }
|
| 5 |
+
header h1 span { color: #f4bf67; }
|
| 6 |
header p { font: 18px/1.6 Georgia, serif; color: #777; }
|
| 7 |
#page textarea { font: 18px/1.65 Georgia, 'Times New Roman', serif !important; padding: 14px 20px !important; }
|
| 8 |
.inspector { padding: 22px; border: 1px solid #82968b40; border-radius: 14px; min-height: 230px; }
|
| 9 |
.inspector h3 { font: 26px/1.2 Georgia, serif; margin: 12px 0; }
|
| 10 |
.inspector p, .inspector small { opacity: .75; line-height: 1.6; }
|
| 11 |
.candidate { padding: 8px 10px; margin: 6px 0; border-radius: 8px; }
|
| 12 |
+
.candidate.selected { background: #f4bf6726; outline: 1px solid #f4bf6780; }
|
| 13 |
.candidate-label { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
|
| 14 |
.candidate-label code { white-space: pre-wrap; overflow-wrap: anywhere; }
|
| 15 |
.candidate small { font-size: 10px; }
|
| 16 |
.track { height: 5px; background: #82968b20; border-radius: 8px; margin: 7px 0 3px; overflow: hidden; }
|
| 17 |
+
.track div { height: 100%; background: #f4bf67; border-radius: 8px; }
|
| 18 |
|
| 19 |
#model-picker { max-width:680px; margin:8vh auto; padding:24px; }
|
| 20 |
#flow-workspace { gap:10px; }
|
|
|
|
| 27 |
.space-top,.space-bottom { position:absolute; left:22px; right:22px; display:flex; justify-content:space-between; gap:16px; pointer-events:none; font:11px/1.5 system-ui,sans-serif; }
|
| 28 |
.space-top { top:18px; letter-spacing:.12em; }
|
| 29 |
.space-bottom { bottom:16px; opacity:.6; }
|
| 30 |
+
.space-brand { color:#f4bf67; }
|
| 31 |
.space-empty { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; pointer-events:none; font:clamp(20px,3vw,34px)/1.4 Georgia,serif; color:#b9d0d4; }
|
| 32 |
.space-empty small { font:13px/1.5 system-ui,sans-serif; opacity:.65; }
|
| 33 |
.space-transport { display:none !important; }
|
|
|
|
| 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:#f4bf67; 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 #f4bf6766; }
|
| 68 |
+
.paused-token-reader button.text-token.is-selected { background:#f4bf67; color:#17242b; box-shadow:0 0 0 2px #f4bf6755; }
|
| 69 |
+
.paused-token-reader button.text-token:focus-visible { outline:2px solid #f4bf67; 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; }}
|
| 72 |
.generation-proxy { display:none !important; }
|
| 73 |
#generation-toggle { border:0 !important; padding:0 !important; background:transparent !important; flex:3 !important; min-width:0 !important; }
|
| 74 |
|
| 75 |
+
.generation-toggle-button { width:100%; min-height:44px; padding:10px 18px; border:0; border-radius:10px; background:#f4bf67; color:#17242b; font:600 16px/1.4 system-ui,sans-serif; cursor:pointer; box-shadow:0 2px 8px #173c381a; }
|
| 76 |
+
.generation-toggle-button:hover { background:#e7aa45; }
|
| 77 |
.generation-toggle-button:disabled { opacity:.65; cursor:wait; }
|
| 78 |
+
.generation-toggle-button:focus-visible { outline:3px solid #f4bf67; outline-offset:2px; }
|
| 79 |
|
| 80 |
/* Model caption and compact reset remain outside the expandable dock. */
|
| 81 |
#text-overlay { position:absolute !important; top:max(18px,env(safe-area-inset-top)); left:clamp(16px,4vw,72px); right:clamp(16px,4vw,72px); width:auto !important; gap:7px !important; z-index:2; }
|
|
|
|
| 84 |
#reset-model { position:absolute !important; right:max(16px,env(safe-area-inset-right)); bottom:max(16px,env(safe-area-inset-bottom)); z-index:8; width:36px !important; height:36px !important; min-width:36px !important; min-height:36px !important; padding:0 !important; border:1px solid #86b6b366 !important; border-radius:50% !important; background:#112530ed !important; color:#c5e2dd !important; font-size:0 !important; box-shadow:0 3px 16px #0004; }
|
| 85 |
#reset-model::before { content:"\21ba"; font:24px/1 system-ui,sans-serif; }
|
| 86 |
#reset-model:hover { background:#23434d !important; color:#fff !important; }
|
| 87 |
+
#reset-model:focus-visible { outline:2px solid #f4bf67; outline-offset:3px; }
|
| 88 |
#control-dock { width:min(940px,calc(100vw - 120px)) !important; }
|
| 89 |
@media(max-width:640px) { #text-overlay { top:12px;left:12px;right:12px;gap:5px !important; } #model-name { font-size:12px;padding:0 16px !important; } #control-dock { left:12px;transform:none;width:calc(100vw - 72px) !important; } #reset-model { right:12px;bottom:12px; } }
|
| 90 |
|
|
|
|
| 95 |
#page { overflow:hidden !important; background:#091622 !important; background-image:none !important; box-shadow:none !important; }
|
| 96 |
#page > div, #page label, #page .input-container, #page .input-container:focus-within { background:transparent !important; background-image:none !important; border:0 !important; box-shadow:none !important; }
|
| 97 |
#page textarea { background:transparent !important; background-image:none !important; border-radius:0 !important; box-shadow:none !important; resize:none !important; }
|
| 98 |
+
|
| 99 |
+
/* Amber links the title punctuation, primary actions, focus and selections. */
|
| 100 |
+
.gradio-container { --primary-400:#f8d49a !important; --primary-500:#f4bf67 !important; --primary-600:#b77a20 !important; --color-accent:#f4bf67 !important; --color-accent-soft:#f4bf6726 !important; }
|
| 101 |
+
#model-picker header { padding:24px 8px 20px; }
|
| 102 |
+
#model-picker header h1 { font-size:clamp(38px,5vw,62px); line-height:1.05; }
|
| 103 |
+
#model-picker header h1 .title-stop { color:#f4bf67 !important; }
|
| 104 |
+
#model-picker header p { font:16px/1.7 system-ui,sans-serif; color:var(--body-text-color); opacity:.85; margin:18px 0 0; }
|
| 105 |
+
#load-model { background:#f4bf67 !important; color:#17242b !important; border-color:#f4bf67 !important; }
|
| 106 |
+
#load-model:hover { background:#e7aa45 !important; border-color:#e7aa45 !important; }
|
| 107 |
+
.space-tools button:hover,.space-tools select:focus-visible { border-color:#f4bf67; }
|
token_space.js
CHANGED
|
@@ -238,7 +238,7 @@
|
|
| 238 |
const byIndex=new Map(rendered.map(p=>[p.n,p]));
|
| 239 |
function line(a,b,score){
|
| 240 |
if(!a||!b)return;const highlight=selected===a.n||selected===b.n;
|
| 241 |
-
ctx.strokeStyle=score==null?`rgba(109,207,196,${Math.min(a.alpha,b.alpha)*(highlight?.9:.25)})`:`rgba(
|
| 242 |
ctx.lineWidth=highlight?2:1;ctx.beginPath();ctx.moveTo(a.x,a.y);ctx.lineTo(b.x,b.y);ctx.stroke();
|
| 243 |
}
|
| 244 |
if(connections==='order')for(const p of rendered)line(byIndex.get(p.n-1),p,null);
|
|
@@ -264,7 +264,7 @@
|
|
| 264 |
rendered.sort((a,b)=>b.z-a.z);hits=rendered;
|
| 265 |
for(const p of rendered){
|
| 266 |
const highlight=p.n===selected,newest=p.n===seen;ctx.globalAlpha=highlight?1:p.alpha;
|
| 267 |
-
ctx.fillStyle=p.ghost?'#bba2eb':highlight?'#
|
| 268 |
ctx.beginPath();ctx.arc(p.x,p.y,Math.max(2,Math.min(12,(newest||highlight?5:3)*p.scale)),0,Math.PI*2);ctx.fill();ctx.shadowBlur=0;
|
| 269 |
ctx.font=`${newest||highlight?600:400} ${Math.max(11,Math.min(19,14*p.scale))}px ui-monospace,monospace`;
|
| 270 |
let label=p.label.replace(/\n/g,'↵').replace(/\t/g,'⇥').replace(/ /g,'·');
|
|
|
|
| 238 |
const byIndex=new Map(rendered.map(p=>[p.n,p]));
|
| 239 |
function line(a,b,score){
|
| 240 |
if(!a||!b)return;const highlight=selected===a.n||selected===b.n;
|
| 241 |
+
ctx.strokeStyle=score==null?`rgba(109,207,196,${Math.min(a.alpha,b.alpha)*(highlight?.9:.25)})`:`rgba(244,191,103,${Math.min(a.alpha,b.alpha)*(highlight?1:.12+.4*Math.max(0,score))})`;
|
| 242 |
ctx.lineWidth=highlight?2:1;ctx.beginPath();ctx.moveTo(a.x,a.y);ctx.lineTo(b.x,b.y);ctx.stroke();
|
| 243 |
}
|
| 244 |
if(connections==='order')for(const p of rendered)line(byIndex.get(p.n-1),p,null);
|
|
|
|
| 264 |
rendered.sort((a,b)=>b.z-a.z);hits=rendered;
|
| 265 |
for(const p of rendered){
|
| 266 |
const highlight=p.n===selected,newest=p.n===seen;ctx.globalAlpha=highlight?1:p.alpha;
|
| 267 |
+
ctx.fillStyle=p.ghost?'#bba2eb':highlight?'#f4bf67':newest?'#faf0bd':'#83dfd2';ctx.shadowColor=ctx.fillStyle;ctx.shadowBlur=newest||highlight?18:8;
|
| 268 |
ctx.beginPath();ctx.arc(p.x,p.y,Math.max(2,Math.min(12,(newest||highlight?5:3)*p.scale)),0,Math.PI*2);ctx.fill();ctx.shadowBlur=0;
|
| 269 |
ctx.font=`${newest||highlight?600:400} ${Math.max(11,Math.min(19,14*p.scale))}px ui-monospace,monospace`;
|
| 270 |
let label=p.label.replace(/\n/g,'↵').replace(/\t/g,'⇥').replace(/ /g,'·');
|
token_space.py
CHANGED
|
@@ -113,7 +113,7 @@ def _frame(flow, store, full=False):
|
|
| 113 |
|
| 114 |
SCENE = '''<div id="token-universe">
|
| 115 |
<canvas aria-label="Live 3D projection of generated token embeddings. Drag to orbit; scroll to zoom."></canvas>
|
| 116 |
-
<div class="space-top"><span class="space-brand">
|
| 117 |
<div class="space-empty">A space for the next thought.<small>Press Begin. Tokens appear here, then fade.</small></div>
|
| 118 |
<div class="space-tools">
|
| 119 |
<label>View <select data-space-mode><option value="live">Live · fade after 6s</option><option value="history">History · last 512 tokens</option></select></label>
|
|
|
|
| 113 |
|
| 114 |
SCENE = '''<div id="token-universe">
|
| 115 |
<canvas aria-label="Live 3D projection of generated token embeddings. Drag to orbit; scroll to zoom."></canvas>
|
| 116 |
+
<div class="space-top"><span class="space-brand">AUTOMATIC TOKEN GENERATION / TOKEN SPACE</span><span class="space-count">Waiting for tokens</span></div>
|
| 117 |
<div class="space-empty">A space for the next thought.<small>Press Begin. Tokens appear here, then fade.</small></div>
|
| 118 |
<div class="space-tools">
|
| 119 |
<label>View <select data-space-mode><option value="live">Live · fade after 6s</option><option value="history">History · last 512 tokens</option></select></label>
|