Spaces:
Running
Running
Alex W. commited on
Commit ·
f38ed3a
1
Parent(s): 0ff8a89
Bug 原因 修复
Browse filesSyntaxWarning: invalid escape sequence '\_' Python 字符串里 \_ 不是合法转义 改用 r"""..."""
no such column: modality 建索引时 modality 列还没加 迁移移到建索引之前
- db/schema.py +7 -8
- ui/tab_leaderboard.py +2 -2
db/schema.py
CHANGED
|
@@ -202,26 +202,25 @@ def _migrate_add_modality(conn: sqlite3.Connection):
|
|
| 202 |
# ─────────────────────────────────────────────
|
| 203 |
|
| 204 |
def init_db() -> sqlite3.Connection:
|
| 205 |
-
"""
|
| 206 |
-
初始化数据库:建表 + 建索引 + 迁移旧数据
|
| 207 |
-
幂等操作,重复调用安全
|
| 208 |
-
"""
|
| 209 |
conn = get_connection()
|
| 210 |
cur = conn.cursor()
|
| 211 |
|
|
|
|
| 212 |
cur.execute(SQL_CREATE_MODELS)
|
| 213 |
cur.execute(SQL_CREATE_COMPONENTS)
|
| 214 |
cur.execute(SQL_CREATE_LAYER_HEAD_METRICS)
|
| 215 |
cur.execute(SQL_CREATE_MODEL_SUMMARY)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
|
|
|
|
|
|
| 217 |
for sql in SQL_CREATE_INDEXES:
|
| 218 |
cur.execute(sql)
|
| 219 |
-
|
| 220 |
conn.commit()
|
| 221 |
|
| 222 |
-
# 旧数据库迁移(新库此函数为空操作)
|
| 223 |
-
_migrate_add_modality(conn)
|
| 224 |
-
|
| 225 |
return conn
|
| 226 |
|
| 227 |
|
|
|
|
| 202 |
# ─────────────────────────────────────────────
|
| 203 |
|
| 204 |
def init_db() -> sqlite3.Connection:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
conn = get_connection()
|
| 206 |
cur = conn.cursor()
|
| 207 |
|
| 208 |
+
# 第一步:建表
|
| 209 |
cur.execute(SQL_CREATE_MODELS)
|
| 210 |
cur.execute(SQL_CREATE_COMPONENTS)
|
| 211 |
cur.execute(SQL_CREATE_LAYER_HEAD_METRICS)
|
| 212 |
cur.execute(SQL_CREATE_MODEL_SUMMARY)
|
| 213 |
+
conn.commit()
|
| 214 |
+
|
| 215 |
+
# 第二步:迁移旧数据(加 modality 列)← 必须在建索引之前
|
| 216 |
+
_migrate_add_modality(conn)
|
| 217 |
|
| 218 |
+
# 第三步:建索引(此时 modality 列已确保存在)
|
| 219 |
+
cur = conn.cursor()
|
| 220 |
for sql in SQL_CREATE_INDEXES:
|
| 221 |
cur.execute(sql)
|
|
|
|
| 222 |
conn.commit()
|
| 223 |
|
|
|
|
|
|
|
|
|
|
| 224 |
return conn
|
| 225 |
|
| 226 |
|
ui/tab_leaderboard.py
CHANGED
|
@@ -69,7 +69,7 @@ def load_leaderboard(
|
|
| 69 |
|
| 70 |
def build_tab_leaderboard():
|
| 71 |
with gr.Tab("🏆 Leaderboard"):
|
| 72 |
-
gr.Markdown("""
|
| 73 |
## Wang's Five Laws — Model Leaderboard
|
| 74 |
|
| 75 |
**Wang Score = 1 − median(SSR\_QK)** Higher is better. Theoretical max = 1.
|
|
@@ -121,7 +121,7 @@ def build_tab_leaderboard():
|
|
| 121 |
wrap=True,
|
| 122 |
)
|
| 123 |
|
| 124 |
-
gr.Markdown("""
|
| 125 |
### Metric Reference | 指标说明
|
| 126 |
|
| 127 |
| Metric | Description | Better |
|
|
|
|
| 69 |
|
| 70 |
def build_tab_leaderboard():
|
| 71 |
with gr.Tab("🏆 Leaderboard"):
|
| 72 |
+
gr.Markdown(r"""
|
| 73 |
## Wang's Five Laws — Model Leaderboard
|
| 74 |
|
| 75 |
**Wang Score = 1 − median(SSR\_QK)** Higher is better. Theoretical max = 1.
|
|
|
|
| 121 |
wrap=True,
|
| 122 |
)
|
| 123 |
|
| 124 |
+
gr.Markdown(r"""
|
| 125 |
### Metric Reference | 指标说明
|
| 126 |
|
| 127 |
| Metric | Description | Better |
|