Spaces:
Sleeping
Sleeping
Commit Β·
73ac613
1
Parent(s): e3ab0f2
cite
Browse files
app.py
CHANGED
|
@@ -245,6 +245,24 @@ CHAIN_CSS = """
|
|
| 245 |
.thinking { font-size: 13px; color: #888; padding: 8px 0; }
|
| 246 |
.empty-hint { font-size: 12px; color: #ccc; padding: 6px 0; }
|
| 247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
.wd {
|
| 249 |
display: inline-block; width: 6px; height: 6px; border-radius: 50%;
|
| 250 |
background: currentColor; margin: 0 2px; opacity: 0.3;
|
|
@@ -340,14 +358,24 @@ def render_chain(s1_text, s2_text, s3_text, status="done"):
|
|
| 340 |
else:
|
| 341 |
s3_content = '<div class="empty-hint">Waiting...</div>'
|
| 342 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
def card(cls, badge, title, content, active):
|
| 344 |
dim = "active" if active else "dim"
|
|
|
|
|
|
|
|
|
|
| 345 |
return f"""
|
| 346 |
<div class="stage-card {cls} {dim}">
|
| 347 |
<div class="stage-header">
|
| 348 |
<span class="stage-badge">{badge}</span>
|
| 349 |
<span class="stage-title">{title}</span>
|
| 350 |
</div>
|
|
|
|
|
|
|
| 351 |
{content}
|
| 352 |
</div>"""
|
| 353 |
|
|
@@ -476,7 +504,13 @@ def on_select_reset(agent_id):
|
|
| 476 |
|
| 477 |
with gr.Blocks(title="HiCoTraj Demo", theme=gr.themes.Soft()) as app:
|
| 478 |
gr.Markdown("## HiCoTraj β Trajectory Visualization & Hierarchical CoT Demo")
|
| 479 |
-
gr.Markdown("*Zero-Shot Demographic Reasoning via Hierarchical Chain-of-Thought Prompting from Trajectory*")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 480 |
|
| 481 |
with gr.Row():
|
| 482 |
agent_dd = gr.Dropdown(
|
|
|
|
| 245 |
.thinking { font-size: 13px; color: #888; padding: 8px 0; }
|
| 246 |
.empty-hint { font-size: 12px; color: #ccc; padding: 6px 0; }
|
| 247 |
|
| 248 |
+
.prompt-snippet {
|
| 249 |
+
font-size: 11px; color: #888; line-height: 1.5;
|
| 250 |
+
background: rgba(0,0,0,0.03); border-left: 2px solid #ddd;
|
| 251 |
+
padding: 6px 10px; border-radius: 0 4px 4px 0;
|
| 252 |
+
margin-bottom: 8px; font-family: 'IBM Plex Mono', monospace;
|
| 253 |
+
}
|
| 254 |
+
.prompt-label {
|
| 255 |
+
display: inline-block; font-size: 9px; font-weight: 600;
|
| 256 |
+
text-transform: uppercase; letter-spacing: 0.08em;
|
| 257 |
+
color: #aaa; margin-right: 6px;
|
| 258 |
+
background: #eee; padding: 1px 5px; border-radius: 3px;
|
| 259 |
+
}
|
| 260 |
+
.resp-label {
|
| 261 |
+
font-size: 9px; font-weight: 600; text-transform: uppercase;
|
| 262 |
+
letter-spacing: 0.08em; color: #aaa; margin-bottom: 4px;
|
| 263 |
+
display: inline-block; background: #eee; padding: 1px 5px; border-radius: 3px;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
.wd {
|
| 267 |
display: inline-block; width: 6px; height: 6px; border-radius: 50%;
|
| 268 |
background: currentColor; margin: 0 2px; opacity: 0.3;
|
|
|
|
| 358 |
else:
|
| 359 |
s3_content = '<div class="empty-hint">Waiting...</div>'
|
| 360 |
|
| 361 |
+
PROMPT_SNIPPETS = {
|
| 362 |
+
"s1": "You are an expert mobility analyst. Given the trajectory data below, extract: (1) LOCATION INVENTORY β list all POI categories visited and visit frequency; (2) TEMPORAL PATTERNS β weekly distribution, peak hours; (3) SEQUENCE β typical activity chains...",
|
| 363 |
+
"s2": "Based on the trajectory features identified: {Response 1}. Now analyze what these mobility patterns reveal about lifestyle: (1) SCHEDULE β work/activity routine type; (2) ECONOMIC β spending venue tiers; (3) SOCIAL β social engagement patterns; (4) LIFESTYLE β activity diversity; (5) STABILITY β consistency of routine...",
|
| 364 |
+
"s3": "Based on feature analysis {Response 1} and behavioral analysis {Response 2}, predict income level. Output format β INCOME_PREDICTION: [Low (<$25k) | Lower-middle ($25kβ$50k) | Middle ($50kβ$100k) | Upper-middle ($100kβ$150k) | High (>$150k)]; INCOME_CONFIDENCE: [1β5]; INCOME_REASONING: [detailed reasoning]...",
|
| 365 |
+
}
|
| 366 |
def card(cls, badge, title, content, active):
|
| 367 |
dim = "active" if active else "dim"
|
| 368 |
+
prompt = PROMPT_SNIPPETS.get(cls, "")
|
| 369 |
+
prompt_html = f'''<div class="prompt-snippet"><span class="prompt-label">Prompt</span>{prompt}</div>''' if prompt else ""
|
| 370 |
+
resp_label = '<div class="resp-label">Response</div>' if active and content and "empty-hint" not in content and "thinking" not in content else ""
|
| 371 |
return f"""
|
| 372 |
<div class="stage-card {cls} {dim}">
|
| 373 |
<div class="stage-header">
|
| 374 |
<span class="stage-badge">{badge}</span>
|
| 375 |
<span class="stage-title">{title}</span>
|
| 376 |
</div>
|
| 377 |
+
{prompt_html}
|
| 378 |
+
{resp_label}
|
| 379 |
{content}
|
| 380 |
</div>"""
|
| 381 |
|
|
|
|
| 504 |
|
| 505 |
with gr.Blocks(title="HiCoTraj Demo", theme=gr.themes.Soft()) as app:
|
| 506 |
gr.Markdown("## HiCoTraj β Trajectory Visualization & Hierarchical CoT Demo")
|
| 507 |
+
gr.Markdown("*Zero-Shot Demographic Reasoning via Hierarchical Chain-of-Thought Prompting from Trajectory* Β· ACM SIGSPATIAL GeoGenAgent 2025")
|
| 508 |
+
gr.Markdown("""
|
| 509 |
+
**Dataset:** NUMOSIM β a synthetic mobility dataset with realistic activity patterns across 6,000 agents.
|
| 510 |
+
> Stanford C, Adari S, Liao X, et al. *NUMoSim: A Synthetic Mobility Dataset with Anomaly Detection Benchmarks.* ACM SIGSPATIAL Workshop on Geospatial Anomaly Detection, 2024.
|
| 511 |
+
|
| 512 |
+
**Map legend:** π΄ Early visits (light red) β π΄ Recent visits (dark red) Β· Each dot = one stay point Β· Click dot for details
|
| 513 |
+
""")
|
| 514 |
|
| 515 |
with gr.Row():
|
| 516 |
agent_dd = gr.Dropdown(
|