Spaces:
Sleeping
Sleeping
Update app.py
Browse filesTightened up spacing.
app.py
CHANGED
|
@@ -24,44 +24,51 @@ model = AutoModelForCausalLM.from_pretrained(MODEL_ID)
|
|
| 24 |
# ---------- Theme & layout (light blue / white / black accents) ----------
|
| 25 |
theme_css = """
|
| 26 |
:root{
|
| 27 |
-
--primary:#38bdf8;
|
| 28 |
-
--
|
| 29 |
-
--text:#0b0f14; /* near-black */
|
| 30 |
-
--muted:#6b7280; /* gray-500 */
|
| 31 |
-
--border:#e5e7eb; /* gray-200 */
|
| 32 |
}
|
| 33 |
-
body{ background:var(--bg); color:var(--text); }
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
border-radius:999px; margin:2px;
|
| 38 |
-
}
|
| 39 |
|
| 40 |
-
/* Two-column layout
|
| 41 |
-
.app-row { display:flex; align-items:flex-start; gap:
|
| 42 |
-
.predictions-panel { flex:0 0
|
| 43 |
-
.plot-panel { flex:1 1 auto;
|
| 44 |
|
| 45 |
-
/* Prediction rows (
|
| 46 |
.rowbtn{
|
| 47 |
-
width:100%;
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
| 49 |
display:flex; justify-content:flex-start; align-items:center;
|
| 50 |
text-align:left; cursor:pointer; user-select:none;
|
| 51 |
-
font-family:
|
|
|
|
|
|
|
| 52 |
letter-spacing:.2px;
|
|
|
|
| 53 |
}
|
| 54 |
.rowbtn:hover{ background:#f7fbff; border-color:#c3e8fb; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
"""
|
| 56 |
|
| 57 |
|
|
|
|
| 58 |
# ---------- Reactive state ----------
|
| 59 |
-
text_rx = solara.reactive("
|
| 60 |
preds_rx = solara.reactive(pd.DataFrame(columns=["probs", "id", "tok"]))
|
| 61 |
selected_token_id_rx = solara.reactive(None)
|
| 62 |
neighbor_list_rx = solara.reactive([])
|
| 63 |
last_hovered_id_rx = solara.reactive(None)
|
| 64 |
-
notice_rx = solara.reactive("Click a candidate (or hover to preview).")
|
| 65 |
auto_running_rx = solara.reactive(True)
|
| 66 |
|
| 67 |
|
|
@@ -141,7 +148,7 @@ def base_scatter():
|
|
| 141 |
hoverinfo="skip",
|
| 142 |
))
|
| 143 |
fig.update_layout(
|
| 144 |
-
height=
|
| 145 |
paper_bgcolor="white", plot_bgcolor="white",
|
| 146 |
xaxis=dict(visible=False), yaxis=dict(visible=False),
|
| 147 |
showlegend=False,
|
|
@@ -289,7 +296,7 @@ def PredictionsList():
|
|
| 289 |
with solara.Column(gap="6px", style={"maxWidth": "720px"}):
|
| 290 |
solara.Markdown("### Prediction")
|
| 291 |
solara.Text(
|
| 292 |
-
" # probs
|
| 293 |
style={
|
| 294 |
"color": "var(--muted)",
|
| 295 |
"fontFamily": 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
|
|
@@ -329,16 +336,15 @@ def PredictionsList():
|
|
| 329 |
def Page():
|
| 330 |
solara.Style(theme_css)
|
| 331 |
|
| 332 |
-
with solara.Column(margin=
|
| 333 |
solara.Markdown("# Next-Token Predictor + Semantic Neighborhood")
|
| 334 |
solara.Markdown(
|
| 335 |
-
"Type text to see predictions
|
| 336 |
-
"Click a
|
| 337 |
-
"Hover a
|
| 338 |
)
|
| 339 |
|
| 340 |
solara.InputText("Enter text", value=text_rx, continuous_update=True, style={"minWidth":"520px"})
|
| 341 |
-
solara.Markdown(f"*{notice_rx.value}*")
|
| 342 |
|
| 343 |
with solara.Row(classes=["app-row"]):
|
| 344 |
with solara.Column(classes=["predictions-panel"]):
|
|
|
|
| 24 |
# ---------- Theme & layout (light blue / white / black accents) ----------
|
| 25 |
theme_css = """
|
| 26 |
:root{
|
| 27 |
+
--primary:#38bdf8; --bg:#ffffff; --text:#0b0f14; --muted:#6b7280; --border:#e5e7eb;
|
| 28 |
+
--mono:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
|
|
|
|
|
|
|
|
| 29 |
}
|
|
|
|
| 30 |
|
| 31 |
+
/* Base */
|
| 32 |
+
body{ background:var(--bg); color:var(--text); }
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
/* Two-column layout */
|
| 35 |
+
.app-row { display:flex; align-items:flex-start; gap:16px; } /* was 24px */
|
| 36 |
+
.predictions-panel { flex:0 0 320px; position:relative; z-index:10;}/* was 360px */
|
| 37 |
+
.plot-panel { flex:1 1 auto; position:relative; z-index:1; overflow:hidden; }
|
| 38 |
|
| 39 |
+
/* Prediction rows (tighter) */
|
| 40 |
.rowbtn{
|
| 41 |
+
width:100%;
|
| 42 |
+
padding:6px 10px; /* was 10px 12px */
|
| 43 |
+
border-radius:10px; /* was 12px */
|
| 44 |
+
border:1px solid var(--border);
|
| 45 |
+
background:#fff; color:var(--text);
|
| 46 |
display:flex; justify-content:flex-start; align-items:center;
|
| 47 |
text-align:left; cursor:pointer; user-select:none;
|
| 48 |
+
font-family: var(--mono);
|
| 49 |
+
font-size:13px; /* was default ~14–16 */
|
| 50 |
+
line-height:1.15;
|
| 51 |
letter-spacing:.2px;
|
| 52 |
+
margin-bottom:6px; /* explicit, keeps list consistent */
|
| 53 |
}
|
| 54 |
.rowbtn:hover{ background:#f7fbff; border-color:#c3e8fb; }
|
| 55 |
+
|
| 56 |
+
/* Neighbor chips (smaller) */
|
| 57 |
+
.badge{
|
| 58 |
+
display:inline-block; padding:2px 6px; /* was 2px 8px */
|
| 59 |
+
border:1px solid var(--border); border-radius:999px; margin:2px;
|
| 60 |
+
font-size:12px; line-height:1.15;
|
| 61 |
+
}
|
| 62 |
"""
|
| 63 |
|
| 64 |
|
| 65 |
+
|
| 66 |
# ---------- Reactive state ----------
|
| 67 |
+
text_rx = solara.reactive("Twinkle, twinkle, little ")
|
| 68 |
preds_rx = solara.reactive(pd.DataFrame(columns=["probs", "id", "tok"]))
|
| 69 |
selected_token_id_rx = solara.reactive(None)
|
| 70 |
neighbor_list_rx = solara.reactive([])
|
| 71 |
last_hovered_id_rx = solara.reactive(None)
|
|
|
|
| 72 |
auto_running_rx = solara.reactive(True)
|
| 73 |
|
| 74 |
|
|
|
|
| 148 |
hoverinfo="skip",
|
| 149 |
))
|
| 150 |
fig.update_layout(
|
| 151 |
+
height=380, margin=dict(l=6,r=6,t=6,b=6),
|
| 152 |
paper_bgcolor="white", plot_bgcolor="white",
|
| 153 |
xaxis=dict(visible=False), yaxis=dict(visible=False),
|
| 154 |
showlegend=False,
|
|
|
|
| 296 |
with solara.Column(gap="6px", style={"maxWidth": "720px"}):
|
| 297 |
solara.Markdown("### Prediction")
|
| 298 |
solara.Text(
|
| 299 |
+
" # probs tokenID next predicted",
|
| 300 |
style={
|
| 301 |
"color": "var(--muted)",
|
| 302 |
"fontFamily": 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
|
|
|
|
| 336 |
def Page():
|
| 337 |
solara.Style(theme_css)
|
| 338 |
|
| 339 |
+
with solara.Column(margin=10, gap="12px"):
|
| 340 |
solara.Markdown("# Next-Token Predictor + Semantic Neighborhood")
|
| 341 |
solara.Markdown(
|
| 342 |
+
"Type text to see AI's top predictions for the next token. "
|
| 343 |
+
"Click a token to append it to your text. "
|
| 344 |
+
"Hover over a token to preview its **semantic neighborhood**."
|
| 345 |
)
|
| 346 |
|
| 347 |
solara.InputText("Enter text", value=text_rx, continuous_update=True, style={"minWidth":"520px"})
|
|
|
|
| 348 |
|
| 349 |
with solara.Row(classes=["app-row"]):
|
| 350 |
with solara.Column(classes=["predictions-panel"]):
|