Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -256,7 +256,7 @@ def cb_attack(idx, src, target):
|
|
| 256 |
return qtxt, gauge, res
|
| 257 |
|
| 258 |
|
| 259 |
-
EVAL_ACC={u"基线
|
| 260 |
u"输出扰动 (\u03c3=0.01)":bl_acc,u"输出扰动 (\u03c3=0.015)":bl_acc,u"输出扰动 (\u03c3=0.02)":bl_acc}
|
| 261 |
EVAL_KEY={u"基线模型":"baseline",u"标签平滑 (\u03b5=0.02)":"smooth_0.02",u"标签平滑 (\u03b5=0.2)":"smooth_0.2",
|
| 262 |
u"输出扰动 (\u03c3=0.01)":"baseline",u"输出扰动 (\u03c3=0.015)":"baseline",u"输出扰动 (\u03c3=0.02)":"baseline"}
|
|
@@ -273,72 +273,212 @@ def cb_eval(model):
|
|
| 273 |
"| 正确答案 | "+q['answer']+" |\n| 判定 | "+ic+" |"+note)
|
| 274 |
|
| 275 |
|
| 276 |
-
# ══════════════
|
| 277 |
|
| 278 |
CSS = """
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
/*
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
border-radius: 8px 8px 0 0 !important; transition: .15s !important; }
|
| 297 |
-
.tab-nav button:hover { color: var(--blue) !important; background: var(--blue-light) !important; }
|
| 298 |
-
.tab-nav button.selected { color: var(--blue) !important; font-weight: 700 !important;
|
| 299 |
-
border-bottom: 2.5px solid var(--blue) !important; background: var(--blue-light) !important; }
|
| 300 |
-
|
| 301 |
-
.tabitem { background: #fff !important; border-radius: 0 0 10px 10px !important;
|
| 302 |
-
box-shadow: 0 1px 4px rgba(0,0,0,.03) !important; padding: 24px 28px !important;
|
| 303 |
-
border: 1px solid #e2e8f0 !important; border-top: none !important; }
|
| 304 |
-
|
| 305 |
-
/* 排版 */
|
| 306 |
-
.prose h2 { font-size: 1.18rem !important; color: #0f172a !important; font-weight: 700 !important;
|
| 307 |
-
margin-top: 1.2em !important; padding-bottom: .3em !important;
|
| 308 |
-
border-bottom: 2px solid #f1f5f9 !important; }
|
| 309 |
-
.prose h3 { font-size: .98rem !important; color: var(--slate) !important; font-weight: 600 !important;
|
| 310 |
-
margin-top: 1em !important; }
|
| 311 |
-
|
| 312 |
-
/* 表格 */
|
| 313 |
-
.prose table { width: 100% !important; border-collapse: separate !important; border-spacing: 0 !important;
|
| 314 |
-
border-radius: 8px !important; overflow: hidden !important; margin: .8em 0 !important;
|
| 315 |
-
box-shadow: 0 0 0 1px #e2e8f0 !important; font-size: .85rem !important; }
|
| 316 |
-
.prose th { background: #f8fafc !important; color: #475569 !important; font-weight: 600 !important;
|
| 317 |
-
padding: 8px 11px !important; border-bottom: 1.5px solid #e2e8f0 !important; font-size: .8rem !important; }
|
| 318 |
-
.prose td { padding: 7px 11px !important; color: var(--slate) !important; border-bottom: 1px solid #f1f5f9 !important; }
|
| 319 |
-
.prose tr:last-child td { border-bottom: none !important; }
|
| 320 |
-
.prose tr:hover td { background: #f8fafc !important; }
|
| 321 |
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
|
|
|
| 326 |
|
| 327 |
-
/*
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 332 |
|
| 333 |
-
/*
|
| 334 |
-
.
|
| 335 |
-
background: white; border: 1px solid #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,.04);
|
| 336 |
-
text-align: center; min-width: 140px; }
|
| 337 |
|
| 338 |
footer { display: none !important; }
|
| 339 |
"""
|
| 340 |
|
| 341 |
-
with gr.Blocks(title="MIA攻防研究", theme=gr.themes.
|
| 342 |
|
| 343 |
gr.HTML("""<div class="title-area">
|
| 344 |
<h1>教育大模型中的成员推理攻击及其防御研究</h1>
|
|
@@ -495,4 +635,4 @@ with gr.Blocks(title="MIA攻防研究", theme=gr.themes.Soft(primary_hue="blue",
|
|
| 495 |
gr.HTML("<div style='text-align:center;color:#94a3b8;font-size:.82rem;padding:16px 0 8px'>"
|
| 496 |
"教育大模型中的成员推理攻击及其防御研究</div>")
|
| 497 |
|
| 498 |
-
demo.launch()
|
|
|
|
| 256 |
return qtxt, gauge, res
|
| 257 |
|
| 258 |
|
| 259 |
+
EVAL_ACC={u"基线模型":bl_acc,u"标签平滑 (\u03b5=0.02)":s002_acc,u"标签平滑 (\u03b5=0.2)":s02_acc,
|
| 260 |
u"输出扰动 (\u03c3=0.01)":bl_acc,u"输出扰动 (\u03c3=0.015)":bl_acc,u"输出扰动 (\u03c3=0.02)":bl_acc}
|
| 261 |
EVAL_KEY={u"基线模型":"baseline",u"标签平滑 (\u03b5=0.02)":"smooth_0.02",u"标签平滑 (\u03b5=0.2)":"smooth_0.2",
|
| 262 |
u"输出扰动 (\u03c3=0.01)":"baseline",u"输出扰动 (\u03c3=0.015)":"baseline",u"输出扰动 (\u03c3=0.02)":"baseline"}
|
|
|
|
| 273 |
"| 正确答案 | "+q['answer']+" |\n| 判定 | "+ic+" |"+note)
|
| 274 |
|
| 275 |
|
| 276 |
+
# ══════════════ 全新高级看板 CSS ══════════════
|
| 277 |
|
| 278 |
CSS = """
|
| 279 |
+
/* ==== 1. 全局科技感色彩基调 ==== */
|
| 280 |
+
:root {
|
| 281 |
+
--primary: #0ea5e9; /* 科技蓝 */
|
| 282 |
+
--primary-dark: #0284c7;
|
| 283 |
+
--primary-light: #e0f2fe;
|
| 284 |
+
--bg-color: #f4f4f5; /* 极浅冷灰底色 */
|
| 285 |
+
--card-bg: #ffffff;
|
| 286 |
+
--text-main: #1e293b;
|
| 287 |
+
--text-muted: #64748b;
|
| 288 |
+
--border-color: #e2e8f0;
|
| 289 |
+
--accent: #38bdf8;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
body {
|
| 293 |
+
background-color: var(--bg-color) !important;
|
| 294 |
+
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif !important;
|
| 295 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
|
| 297 |
+
.gradio-container {
|
| 298 |
+
max-width: 1280px !important; /* 加宽以适应大屏演示 */
|
| 299 |
+
margin: 30px auto !important;
|
| 300 |
+
background: transparent !important;
|
| 301 |
+
}
|
| 302 |
|
| 303 |
+
/* ==== 2. 顶部 Header 设计 ==== */
|
| 304 |
+
.title-area {
|
| 305 |
+
text-align: left;
|
| 306 |
+
padding: 24px 32px;
|
| 307 |
+
margin-bottom: 24px;
|
| 308 |
+
background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); /* 深邃夜空色 */
|
| 309 |
+
border-radius: 12px;
|
| 310 |
+
color: white;
|
| 311 |
+
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
|
| 312 |
+
position: relative;
|
| 313 |
+
overflow: hidden;
|
| 314 |
+
}
|
| 315 |
+
/* 增加网格装饰背景增加科技感 */
|
| 316 |
+
.title-area::after {
|
| 317 |
+
content: '';
|
| 318 |
+
position: absolute;
|
| 319 |
+
top: 0; right: 0; bottom: 0; left: 0;
|
| 320 |
+
background-image: radial-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px);
|
| 321 |
+
background-size: 20px 20px;
|
| 322 |
+
opacity: 0.5;
|
| 323 |
+
pointer-events: none;
|
| 324 |
+
}
|
| 325 |
+
.title-area h1 {
|
| 326 |
+
color: #f8fafc !important;
|
| 327 |
+
font-size: 1.8rem !important;
|
| 328 |
+
font-weight: 700 !important;
|
| 329 |
+
margin: 0 0 8px 0 !important;
|
| 330 |
+
letter-spacing: 0.5px !important;
|
| 331 |
+
}
|
| 332 |
+
.title-area p {
|
| 333 |
+
color: #94a3b8 !important;
|
| 334 |
+
font-size: 0.95rem !important;
|
| 335 |
+
margin: 0 !important;
|
| 336 |
+
text-transform: uppercase;
|
| 337 |
+
letter-spacing: 1px;
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
/* ==== 3. 统一高度与沉浸式卡片 (解决高度跳动) ==== */
|
| 341 |
+
/* 强制所有 Tab 内容区拥有相同的最小/最大高度,并允许内部滚动 */
|
| 342 |
+
.tabitem {
|
| 343 |
+
background: var(--card-bg) !important;
|
| 344 |
+
border-radius: 0 0 12px 12px !important;
|
| 345 |
+
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05) !important;
|
| 346 |
+
padding: 32px 40px !important;
|
| 347 |
+
border: 1px solid var(--border-color) !important;
|
| 348 |
+
border-top: none !important;
|
| 349 |
+
height: 75vh !important; /* 核心:固定高度为视口高度的 75% */
|
| 350 |
+
min-height: 700px !important;
|
| 351 |
+
overflow-y: auto !important; /* 内容超长时出现滚动条 */
|
| 352 |
+
overflow-x: hidden !important;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
/* 美化内部滚动条 */
|
| 356 |
+
.tabitem::-webkit-scrollbar { width: 8px; }
|
| 357 |
+
.tabitem::-webkit-scrollbar-track { background: transparent; }
|
| 358 |
+
.tabitem::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
|
| 359 |
+
.tabitem::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
|
| 360 |
+
|
| 361 |
+
/* ==== 4. Tab 导航玻璃拟态设计 ==== */
|
| 362 |
+
.tab-nav {
|
| 363 |
+
border-bottom: none !important;
|
| 364 |
+
gap: 8px !important;
|
| 365 |
+
padding: 0 12px !important;
|
| 366 |
+
background: transparent !important;
|
| 367 |
+
}
|
| 368 |
+
.tab-nav button {
|
| 369 |
+
font-size: 14.5px !important;
|
| 370 |
+
padding: 12px 24px !important;
|
| 371 |
+
font-weight: 600 !important;
|
| 372 |
+
color: var(--text-muted) !important;
|
| 373 |
+
background: #e2e8f0 !important;
|
| 374 |
+
border: 1px solid var(--border-color) !important;
|
| 375 |
+
border-bottom: none !important;
|
| 376 |
+
border-radius: 10px 10px 0 0 !important;
|
| 377 |
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
| 378 |
+
margin-bottom: -1px !important; /* 连接无缝 */
|
| 379 |
+
}
|
| 380 |
+
.tab-nav button:hover {
|
| 381 |
+
color: var(--primary) !important;
|
| 382 |
+
background: #f8fafc !important;
|
| 383 |
+
}
|
| 384 |
+
.tab-nav button.selected {
|
| 385 |
+
color: var(--primary-dark) !important;
|
| 386 |
+
background: var(--card-bg) !important;
|
| 387 |
+
border-top: 3px solid var(--primary) !important;
|
| 388 |
+
z-index: 2 !important;
|
| 389 |
+
box-shadow: 0 -4px 6px -2px rgba(0,0,0,0.02) !important;
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
/* ==== 5. 高级感排版 (Typography) ==== */
|
| 393 |
+
.prose h2 {
|
| 394 |
+
display: flex; align-items: center;
|
| 395 |
+
font-size: 1.35rem !important;
|
| 396 |
+
color: var(--text-main) !important;
|
| 397 |
+
font-weight: 700 !important;
|
| 398 |
+
margin-top: 1.5em !important;
|
| 399 |
+
padding-bottom: 8px !important;
|
| 400 |
+
border-bottom: 1px solid var(--border-color) !important;
|
| 401 |
+
}
|
| 402 |
+
/* 给 H2 加一个科技蓝竖线修饰 */
|
| 403 |
+
.prose h2::before {
|
| 404 |
+
content: ''; display: inline-block;
|
| 405 |
+
width: 5px; height: 22px;
|
| 406 |
+
background: var(--primary);
|
| 407 |
+
margin-right: 12px; border-radius: 3px;
|
| 408 |
+
}
|
| 409 |
+
.prose h3 {
|
| 410 |
+
font-size: 1.1rem !important;
|
| 411 |
+
color: var(--text-main) !important;
|
| 412 |
+
font-weight: 600 !important;
|
| 413 |
+
margin-top: 1.5em !important;
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
/* ==== 6. 数据看板表格 (Data Tables) ==== */
|
| 417 |
+
.prose table {
|
| 418 |
+
width: 100% !important;
|
| 419 |
+
border-collapse: separate !important;
|
| 420 |
+
border-spacing: 0 !important;
|
| 421 |
+
border-radius: 8px !important;
|
| 422 |
+
overflow: hidden !important;
|
| 423 |
+
margin: 1.2em 0 !important;
|
| 424 |
+
border: 1px solid var(--border-color) !important;
|
| 425 |
+
font-size: 0.9rem !important;
|
| 426 |
+
}
|
| 427 |
+
.prose th {
|
| 428 |
+
background: #f8fafc !important;
|
| 429 |
+
color: var(--text-muted) !important;
|
| 430 |
+
font-weight: 600 !important;
|
| 431 |
+
padding: 12px 16px !important;
|
| 432 |
+
border-bottom: 1px solid var(--border-color) !important;
|
| 433 |
+
text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.8rem !important;
|
| 434 |
+
}
|
| 435 |
+
.prose tr:nth-child(even) td { background: #f8fafc !important; }
|
| 436 |
+
.prose td {
|
| 437 |
+
padding: 10px 16px !important;
|
| 438 |
+
color: var(--text-main) !important;
|
| 439 |
+
border-bottom: 1px solid #f1f5f9 !important;
|
| 440 |
+
}
|
| 441 |
+
.prose tr:last-child td { border-bottom: none !important; }
|
| 442 |
+
.prose tr:hover td { background: var(--primary-light) !important; }
|
| 443 |
+
|
| 444 |
+
/* ==== 7. 提示框组件 (Alert Panels) ==== */
|
| 445 |
+
.prose blockquote {
|
| 446 |
+
border-left: 4px solid var(--primary) !important;
|
| 447 |
+
background: #f0f9ff !important;
|
| 448 |
+
padding: 16px 20px !important;
|
| 449 |
+
border-radius: 0 8px 8px 0 !important;
|
| 450 |
+
color: #0369a1 !important;
|
| 451 |
+
font-size: 0.95rem !important;
|
| 452 |
+
margin: 1em 0 !important;
|
| 453 |
+
box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.1);
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
/* ==== 8. 交互按钮 (Interactive Buttons) ==== */
|
| 457 |
+
button.primary {
|
| 458 |
+
background: var(--primary) !important;
|
| 459 |
+
color: white !important;
|
| 460 |
+
border: none !important;
|
| 461 |
+
box-shadow: 0 4px 6px -1px rgba(14, 165, 233, 0.3) !important;
|
| 462 |
+
font-weight: 600 !important;
|
| 463 |
+
border-radius: 6px !important;
|
| 464 |
+
padding: 10px 24px !important;
|
| 465 |
+
transition: all 0.2s ease !important;
|
| 466 |
+
text-transform: uppercase !important;
|
| 467 |
+
letter-spacing: 0.5px !important;
|
| 468 |
+
}
|
| 469 |
+
button.primary:hover {
|
| 470 |
+
background: var(--primary-dark) !important;
|
| 471 |
+
transform: translateY(-2px) !important;
|
| 472 |
+
box-shadow: 0 6px 12px -2px rgba(14, 165, 233, 0.4) !important;
|
| 473 |
+
}
|
| 474 |
|
| 475 |
+
/* 输入框等表单元素微调 */
|
| 476 |
+
.wrap { box-shadow: none !important; border-color: var(--border-color) !important; }
|
|
|
|
|
|
|
| 477 |
|
| 478 |
footer { display: none !important; }
|
| 479 |
"""
|
| 480 |
|
| 481 |
+
with gr.Blocks(title="MIA攻防研究", theme=gr.themes.Base(), css=CSS) as demo:
|
| 482 |
|
| 483 |
gr.HTML("""<div class="title-area">
|
| 484 |
<h1>教育大模型中的成员推理攻击及其防御研究</h1>
|
|
|
|
| 635 |
gr.HTML("<div style='text-align:center;color:#94a3b8;font-size:.82rem;padding:16px 0 8px'>"
|
| 636 |
"教育大模型中的成员推理攻击及其防御研究</div>")
|
| 637 |
|
| 638 |
+
demo.launch()
|