abir-hr196 commited on
Commit
5c14a51
·
1 Parent(s): e03518e
Files changed (1) hide show
  1. app.py +44 -223
app.py CHANGED
@@ -10,254 +10,79 @@ custom_css = """
10
  --martian-gray-medium: #2A2A2A;
11
  }
12
 
13
- /* FORCE DARK MODE - Override Gradio's light mode */
14
- .gradio-container, .gradio-container * {
15
- color-scheme: dark !important;
16
- }
17
-
18
  .gradio-container {
19
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
20
- background-color: var(--martian-black) !important;
21
- color: #E0E0E0 !important;
22
- }
23
-
24
- /* Force dark backgrounds everywhere */
25
- .block, .panel, div, section {
26
- background-color: var(--martian-black) !important;
27
- }
28
-
29
- /* Force text colors */
30
- h1, h2, h3, h4, h5, h6, p, span, label, div {
31
- color: #E0E0E0 !important;
32
- }
33
-
34
- /* Better tabs - bold, bigger, no icons, ORANGE selection */
35
- .tab-nav {
36
- border-bottom: 2px solid var(--martian-gray-dark) !important;
37
- background: var(--martian-gray-dark) !important;
38
- padding: 0.5rem 1rem !important;
39
- border-radius: 12px 12px 0 0 !important;
40
  }
41
 
 
42
  .tab-nav button {
43
- font-size: 1.2rem !important;
44
- font-weight: 700 !important;
45
- padding: 1rem 2rem !important;
46
- border-radius: 8px !important;
47
- margin: 0 0.25rem !important;
48
- transition: all 0.3s ease !important;
49
- color: #888 !important;
50
- border: none !important;
51
- background: transparent !important;
52
- }
53
-
54
- .tab-nav button:hover {
55
- background: var(--martian-gray-medium) !important;
56
- color: #E0E0E0 !important;
57
  }
58
 
59
  .tab-nav button.selected {
60
  background: var(--martian-orange) !important;
61
  color: white !important;
62
- box-shadow: 0 2px 8px rgba(255, 107, 74, 0.3) !important;
63
- }
64
-
65
- /* Orange labels */
66
- label, .label-wrap {
67
- color: #E0E0E0 !important;
68
  }
69
 
70
- .label-wrap span {
 
71
  background: var(--martian-orange) !important;
72
  color: white !important;
73
- padding: 0.35rem 0.75rem !important;
74
- border-radius: 6px !important;
75
- font-weight: 600 !important;
76
- font-size: 0.9rem !important;
 
77
  }
78
 
79
- /* Orange inputs */
80
- select, input, textarea {
81
- background: var(--martian-gray-medium) !important;
82
- border: 1px solid #3A3A3A !important;
83
- color: #E0E0E0 !important;
84
  }
85
 
86
- select:focus, input:focus, textarea:focus {
87
- border-color: var(--martian-orange) !important;
88
- outline: none !important;
89
- box-shadow: 0 0 0 2px rgba(255, 107, 74, 0.2) !important;
90
  }
91
 
92
- /* Orange sliders */
93
- input[type="range"] {
94
- -webkit-appearance: none;
95
- appearance: none;
96
- background: transparent;
97
- cursor: pointer;
98
  }
99
 
100
- input[type="range"]::-webkit-slider-track {
101
- background: #3A3A3A;
102
- height: 6px;
103
- border-radius: 3px;
104
  }
105
 
106
  input[type="range"]::-webkit-slider-thumb {
107
- -webkit-appearance: none;
108
- appearance: none;
109
- background: var(--martian-orange);
110
- height: 18px;
111
- width: 18px;
112
- border-radius: 50%;
113
- cursor: pointer;
114
- margin-top: -6px;
115
- box-shadow: 0 2px 4px rgba(255, 107, 74, 0.3);
116
- }
117
-
118
- input[type="range"]::-moz-range-track {
119
- background: #3A3A3A;
120
- height: 6px;
121
- border-radius: 3px;
122
  }
123
 
124
  input[type="range"]::-moz-range-thumb {
125
- background: var(--martian-orange);
126
- height: 18px;
127
- width: 18px;
128
- border-radius: 50%;
129
- cursor: pointer;
130
- border: none;
131
- box-shadow: 0 2px 4px rgba(255, 107, 74, 0.3);
132
- }
133
-
134
- input[type="range"]::-moz-range-progress {
135
- background: var(--martian-orange);
136
- height: 6px;
137
- border-radius: 3px;
138
  }
139
 
140
- /* Orange buttons */
141
- .primary, .secondary {
142
  background: var(--martian-orange) !important;
143
  border-color: var(--martian-orange) !important;
144
- color: white !important;
145
- }
146
-
147
- button {
148
- border: none !important;
149
- color: #E0E0E0 !important;
150
- }
151
-
152
- /* Compact header */
153
- .compact-header {
154
- text-align: center;
155
- padding: 1.5rem 0 1rem 0;
156
- background: var(--martian-black);
157
- }
158
-
159
- .compact-header img {
160
- height: 35px;
161
- margin-bottom: 0.5rem;
162
- }
163
-
164
- .compact-header h1 {
165
- font-size: 2rem;
166
- font-weight: 700;
167
- color: #FF6B4A;
168
- margin: 0;
169
- line-height: 1.2;
170
- }
171
-
172
- .compact-header p {
173
- color: #999;
174
- font-size: 0.95rem;
175
- margin-top: 0.25rem;
176
- }
177
-
178
- /* Footer */
179
- .footer {
180
- text-align: center;
181
- padding: 2rem 0;
182
- margin-top: 3rem;
183
- border-top: 2px solid var(--martian-gray-dark);
184
- background: var(--martian-gray-dark);
185
- border-radius: 12px;
186
- }
187
-
188
- .footer-logo {
189
- width: 80px !important;
190
- height: auto !important;
191
- margin: 1rem auto !important;
192
- opacity: 0.9;
193
- transition: opacity 0.3s ease;
194
- display: block;
195
- }
196
-
197
- .footer-logo:hover {
198
- opacity: 1;
199
- }
200
-
201
- .footer-text {
202
- color: #999 !important;
203
- font-size: 0.95rem;
204
- margin: 0.5rem 0;
205
- }
206
-
207
- .footer-text .heart {
208
- color: var(--martian-orange);
209
- animation: heartbeat 1.5s ease-in-out infinite;
210
- }
211
-
212
- .footer-text a {
213
- color: #FF6B4A !important;
214
- }
215
-
216
- @keyframes heartbeat {
217
- 0%, 100% { transform: scale(1); }
218
- 50% { transform: scale(1.1); }
219
- }
220
-
221
- .citation-box {
222
- background: #2A2A2A !important;
223
- border: 1px solid #3A3A3A;
224
- border-radius: 12px;
225
- padding: 1.5rem;
226
- margin: 2rem auto;
227
- max-width: 900px;
228
- font-family: 'Monaco', 'Courier New', monospace;
229
- font-size: 0.85rem;
230
- }
231
-
232
- .citation-header {
233
- font-weight: 700;
234
- color: #FF6B4A !important;
235
- margin-bottom: 1rem;
236
- font-size: 1.1rem;
237
- text-align: center;
238
- }
239
-
240
- .citation-box pre {
241
- color: #D0D0D0 !important;
242
- background: #1A1A1A !important;
243
- padding: 1rem;
244
- border-radius: 8px;
245
- overflow-x: auto;
246
- margin: 0;
247
  }
248
  """
249
 
250
- with gr.Blocks(css=custom_css, title="TinySQL Demo", theme=gr.themes.Soft()) as demo:
251
- # Compact Header
252
  gr.HTML("""
253
- <div class="compact-header">
254
- <img src="file/static/images/martian_logo.jpg" alt="Martian">
255
- <h1>TinySQL</h1>
256
- <p>Mechanistic Interpretability for Text-to-SQL</p>
257
  </div>
258
  """)
259
 
260
- # Shared state for passing data between tabs
261
  shared_instruction = gr.State("")
262
  shared_schema = gr.State("")
263
 
@@ -268,11 +93,11 @@ with gr.Blocks(css=custom_css, title="TinySQL Demo", theme=gr.themes.Soft()) as
268
  with gr.Tab("Model Demo"):
269
  model_components = model_demo(shared_instruction, shared_schema)
270
 
271
- # Citation section
272
  gr.HTML("""
273
- <div class="citation-box">
274
- <div class="citation-header">Cite Our Work</div>
275
- <pre>@misc{harrasse2025tinysqlprogressivetexttosqldataset,
 
276
  title={TinySQL: A Progressive Text-to-SQL Dataset for Mechanistic Interpretability Research},
277
  author={Abir Harrasse and Philip Quirke and Clement Neo and Dhruv Nathawani and Luke Marks and Amir Abdullah},
278
  year={2025},
@@ -281,20 +106,16 @@ with gr.Blocks(css=custom_css, title="TinySQL Demo", theme=gr.themes.Soft()) as
281
  primaryClass={cs.LG},
282
  url={https://arxiv.org/abs/2503.12730}
283
  }</pre>
 
284
  </div>
285
  """)
286
 
287
- # Footer with Martian branding
288
  gr.HTML("""
289
- <div class="footer">
290
- <p class="footer-text">
291
- Brought to you with <span class="heart">❤️</span> from the Martian science team
292
- </p>
293
- <img src="abir-hr196/tinysql-demo/static/images/martian_logo.jpg" alt="Martian" class="footer-logo">
294
- <p class="footer-text" style="font-size: 0.85rem; margin-top: 1rem;">
295
- <a href="https://arxiv.org/abs/2503.12730">Paper</a> •
296
- <a href="https://github.com/withmartian/TinySQL">Code</a> •
297
- <a href="https://huggingface.co/collections/withmartian/tinysql-6760e92748b63fa56a6ffc9f">Dataset</a>
298
  </p>
299
  </div>
300
  """)
 
10
  --martian-gray-medium: #2A2A2A;
11
  }
12
 
 
 
 
 
 
13
  .gradio-container {
14
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
 
17
+ /* TABS - Bigger and bolder */
18
  .tab-nav button {
19
+ font-size: 1.6rem !important;
20
+ font-weight: 800 !important;
21
+ padding: 1.25rem 2.5rem !important;
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
 
24
  .tab-nav button.selected {
25
  background: var(--martian-orange) !important;
26
  color: white !important;
 
 
 
 
 
 
27
  }
28
 
29
+ /* ORANGE RECTANGLE LABELS - Force in both light and dark mode */
30
+ label span, .label-wrap span {
31
  background: var(--martian-orange) !important;
32
  color: white !important;
33
+ padding: 0.5rem 1rem !important;
34
+ border-radius: 8px !important;
35
+ font-weight: 700 !important;
36
+ font-size: 0.95rem !important;
37
+ display: inline-block !important;
38
  }
39
 
40
+ /* Fix CS1, CS2 etc visibility in light mode */
41
+ .dataset-info strong {
42
+ color: #000 !important;
 
 
43
  }
44
 
45
+ @media (prefers-color-scheme: dark) {
46
+ .dataset-info strong {
47
+ color: #E0E0E0 !important;
48
+ }
49
  }
50
 
51
+ /* Citation box - match container background */
52
+ .citation-content {
53
+ background: #2A2A2A !important;
54
+ padding: 1rem !important;
55
+ border-radius: 8px !important;
 
56
  }
57
 
58
+ .citation-content pre {
59
+ background: #1A1A1A !important;
60
+ color: #D0D0D0 !important;
61
+ margin: 0 !important;
62
  }
63
 
64
  input[type="range"]::-webkit-slider-thumb {
65
+ background: var(--martian-orange) !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
 
68
  input[type="range"]::-moz-range-thumb {
69
+ background: var(--martian-orange) !important;
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
+ .primary {
 
73
  background: var(--martian-orange) !important;
74
  border-color: var(--martian-orange) !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
76
  """
77
 
78
+ with gr.Blocks(css=custom_css, title="TinySQL Demo") as demo:
 
79
  gr.HTML("""
80
+ <div style="text-align: center; padding: 1.5rem 0 1rem 0;">
81
+ <h1 style="font-size: 2rem; font-weight: 700; color: #FF6B4A; margin: 0;">TinySQL</h1>
82
+ <p style="color: #999; font-size: 0.95rem; margin-top: 0.25rem;">Mechanistic Interpretability for Text-to-SQL</p>
 
83
  </div>
84
  """)
85
 
 
86
  shared_instruction = gr.State("")
87
  shared_schema = gr.State("")
88
 
 
93
  with gr.Tab("Model Demo"):
94
  model_components = model_demo(shared_instruction, shared_schema)
95
 
 
96
  gr.HTML("""
97
+ <div style="border-radius: 12px; padding: 1.5rem; margin: 2rem auto; max-width: 900px; background: #2A2A2A;">
98
+ <div style="font-weight: 700; color: #FF6B4A; margin-bottom: 1rem; font-size: 1.1rem; text-align: center;">Cite Our Work</div>
99
+ <div class="citation-content">
100
+ <pre style="font-family: 'Monaco', monospace; font-size: 0.85rem; overflow-x: auto;">@misc{harrasse2025tinysqlprogressivetexttosqldataset,
101
  title={TinySQL: A Progressive Text-to-SQL Dataset for Mechanistic Interpretability Research},
102
  author={Abir Harrasse and Philip Quirke and Clement Neo and Dhruv Nathawani and Luke Marks and Amir Abdullah},
103
  year={2025},
 
106
  primaryClass={cs.LG},
107
  url={https://arxiv.org/abs/2503.12730}
108
  }</pre>
109
+ </div>
110
  </div>
111
  """)
112
 
 
113
  gr.HTML("""
114
+ <div style="text-align: center; padding: 2rem 0; margin-top: 3rem;">
115
+ <p style="font-size: 0.85rem; margin-top: 1rem;">
116
+ <a href="https://arxiv.org/abs/2503.12730" style="color: #FF6B4A;">Paper</a>
117
+ <a href="https://github.com/withmartian/TinySQL" style="color: #FF6B4A;">Code</a>
118
+ <a href="https://huggingface.co/collections/withmartian/tinysql-6760e92748b63fa56a6ffc9f" style="color: #FF6B4A;">Dataset</a>
 
 
 
 
119
  </p>
120
  </div>
121
  """)