File size: 7,586 Bytes
e07e1fe
cb9c774
0c2e6b9
38a8f52
cb9c774
 
 
 
f35a40c
0e1846b
cb9c774
38a8f52
e03518e
763946d
 
 
 
cb9c774
 
 
763946d
 
 
e03518e
763946d
 
 
 
e03518e
763946d
 
cb9c774
 
e03518e
0e1846b
 
 
 
 
 
 
cb9c774
e03518e
 
 
0e1846b
 
 
 
f72a9c9
763946d
0e1846b
 
 
 
 
cb9c774
 
 
0e1846b
 
 
 
 
e03518e
599e176
 
 
 
e03518e
599e176
 
e03518e
 
 
 
599e176
 
e03518e
f72a9c9
599e176
f72a9c9
 
 
 
 
 
 
 
 
 
e03518e
f72a9c9
a6c02ed
 
 
 
599e176
 
a6c02ed
 
 
 
599e176
 
a6c02ed
 
 
 
 
 
 
 
 
 
599e176
 
a6c02ed
 
 
 
f72a9c9
 
a6c02ed
 
 
 
 
 
 
 
f72a9c9
 
e03518e
 
 
 
 
 
 
599e176
 
 
763946d
599e176
 
f72a9c9
 
763946d
 
 
e03518e
763946d
 
 
 
 
 
e03518e
 
 
 
 
763946d
 
 
 
 
 
 
 
 
 
 
 
f72a9c9
 
e03518e
0e1846b
 
 
 
 
 
 
 
 
e03518e
 
 
 
 
 
 
 
 
 
 
 
 
0e1846b
763946d
0e1846b
 
 
 
 
 
 
 
 
763946d
 
 
 
0e1846b
 
 
cb9c774
f72a9c9
 
e03518e
 
 
 
 
 
 
 
f72a9c9
 
 
e03518e
763946d
e03518e
 
 
f72a9c9
 
 
763946d
e03518e
 
 
 
 
f72a9c9
cb9c774
0c2e6b9
0e1846b
e03518e
0e1846b
763946d
e03518e
763946d
 
0e1846b
 
 
e03518e
f35a40c
 
 
cb9c774
599e176
f35a40c
 
599e176
f35a40c
0e1846b
e03518e
f72a9c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e03518e
0e1846b
 
 
 
 
e03518e
0e1846b
763946d
 
 
0e1846b
 
 
cb9c774
 
0e1846b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
from tinysql_model_demo import model_demo
from tinysql_dataset_viewer import dataset_viewer
import gradio as gr

custom_css = """
:root {
    --martian-orange: #FF6B4A;
    --martian-black: #0A0A0A;
    --martian-gray-dark: #1A1A1A;
    --martian-gray-medium: #2A2A2A;
}

/* FORCE DARK MODE - Override Gradio's light mode */
.gradio-container, .gradio-container * {
    color-scheme: dark !important;
}

.gradio-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--martian-black) !important;
    color: #E0E0E0 !important;
}

/* Force dark backgrounds everywhere */
.block, .panel, div, section {
    background-color: var(--martian-black) !important;
}

/* Force text colors */
h1, h2, h3, h4, h5, h6, p, span, label, div {
    color: #E0E0E0 !important;
}

/* Better tabs - bold, bigger, no icons, ORANGE selection */
.tab-nav {
    border-bottom: 2px solid var(--martian-gray-dark) !important;
    background: var(--martian-gray-dark) !important;
    padding: 0.5rem 1rem !important;
    border-radius: 12px 12px 0 0 !important;
}

.tab-nav button {
    font-size: 1.2rem !important;
    font-weight: 700 !important;
    padding: 1rem 2rem !important;
    border-radius: 8px !important;
    margin: 0 0.25rem !important;
    transition: all 0.3s ease !important;
    color: #888 !important;
    border: none !important;
    background: transparent !important;
}

.tab-nav button:hover {
    background: var(--martian-gray-medium) !important;
    color: #E0E0E0 !important;
}

.tab-nav button.selected {
    background: var(--martian-orange) !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(255, 107, 74, 0.3) !important;
}

/* Orange labels */
label, .label-wrap {
    color: #E0E0E0 !important;
}

.label-wrap span {
    background: var(--martian-orange) !important;
    color: white !important;
    padding: 0.35rem 0.75rem !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    font-size: 0.9rem !important;
}

/* Orange inputs */
select, input, textarea {
    background: var(--martian-gray-medium) !important;
    border: 1px solid #3A3A3A !important;
    color: #E0E0E0 !important;
}

select:focus, input:focus, textarea:focus {
    border-color: var(--martian-orange) !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(255, 107, 74, 0.2) !important;
}

/* Orange sliders */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-track {
    background: #3A3A3A;
    height: 6px;
    border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background: var(--martian-orange);
    height: 18px;
    width: 18px;
    border-radius: 50%;
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 2px 4px rgba(255, 107, 74, 0.3);
}

input[type="range"]::-moz-range-track {
    background: #3A3A3A;
    height: 6px;
    border-radius: 3px;
}

input[type="range"]::-moz-range-thumb {
    background: var(--martian-orange);
    height: 18px;
    width: 18px;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(255, 107, 74, 0.3);
}

input[type="range"]::-moz-range-progress {
    background: var(--martian-orange);
    height: 6px;
    border-radius: 3px;
}

/* Orange buttons */
.primary, .secondary {
    background: var(--martian-orange) !important;
    border-color: var(--martian-orange) !important;
    color: white !important;
}

button {
    border: none !important;
    color: #E0E0E0 !important;
}

/* Compact header */
.compact-header {
    text-align: center;
    padding: 1.5rem 0 1rem 0;
    background: var(--martian-black);
}

.compact-header img {
    height: 35px;
    margin-bottom: 0.5rem;
}

.compact-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #FF6B4A;
    margin: 0;
    line-height: 1.2;
}

.compact-header p {
    color: #999;
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    border-top: 2px solid var(--martian-gray-dark);
    background: var(--martian-gray-dark);
    border-radius: 12px;
}

.footer-logo {
    width: 80px !important;
    height: auto !important;
    margin: 1rem auto !important;
    opacity: 0.9;
    transition: opacity 0.3s ease;
    display: block;
}

.footer-logo:hover {
    opacity: 1;
}

.footer-text {
    color: #999 !important;
    font-size: 0.95rem;
    margin: 0.5rem 0;
}

.footer-text .heart {
    color: var(--martian-orange);
    animation: heartbeat 1.5s ease-in-out infinite;
}

.footer-text a {
    color: #FF6B4A !important;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.citation-box {
    background: #2A2A2A !important;
    border: 1px solid #3A3A3A;
    border-radius: 12px;
    padding: 1.5rem;
    margin: 2rem auto;
    max-width: 900px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
}

.citation-header {
    font-weight: 700;
    color: #FF6B4A !important;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    text-align: center;
}

.citation-box pre {
    color: #D0D0D0 !important;
    background: #1A1A1A !important;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0;
}
"""

with gr.Blocks(css=custom_css, title="TinySQL Demo", theme=gr.themes.Soft()) as demo:
    # Compact Header
    gr.HTML("""
        <div class="compact-header">
            <img src="file/static/images/martian_logo.jpg" alt="Martian">
            <h1>TinySQL</h1>
            <p>Mechanistic Interpretability for Text-to-SQL</p>
        </div>
    """)
    
    # Shared state for passing data between tabs
    shared_instruction = gr.State("")
    shared_schema = gr.State("")
    
    with gr.Tabs():
        with gr.Tab("Dataset Viewer"):
            viewer_components = dataset_viewer(shared_instruction, shared_schema)
        
        with gr.Tab("Model Demo"):
            model_components = model_demo(shared_instruction, shared_schema)
    
    # Citation section
    gr.HTML("""
        <div class="citation-box">
            <div class="citation-header">Cite Our Work</div>
            <pre>@misc{harrasse2025tinysqlprogressivetexttosqldataset,
    title={TinySQL: A Progressive Text-to-SQL Dataset for Mechanistic Interpretability Research}, 
    author={Abir Harrasse and Philip Quirke and Clement Neo and Dhruv Nathawani and Luke Marks and Amir Abdullah},
    year={2025},
    eprint={2503.12730},
    archivePrefix={arXiv},
    primaryClass={cs.LG},
    url={https://arxiv.org/abs/2503.12730}
}</pre>
        </div>
    """)
    
    # Footer with Martian branding
    gr.HTML("""
        <div class="footer">
            <p class="footer-text">
                Brought to you with <span class="heart">❤️</span> from the Martian science team
            </p>
            <img src="abir-hr196/tinysql-demo/static/images/martian_logo.jpg" alt="Martian" class="footer-logo">
            <p class="footer-text" style="font-size: 0.85rem; margin-top: 1rem;">
                <a href="https://arxiv.org/abs/2503.12730">Paper</a> • 
                <a href="https://github.com/withmartian/TinySQL">Code</a> • 
                <a href="https://huggingface.co/collections/withmartian/tinysql-6760e92748b63fa56a6ffc9f">Dataset</a>
            </p>
        </div>
    """)

if __name__ == "__main__":
    demo.launch(ssr_mode=False)