Spaces:
Sleeping
Sleeping
Commit
·
599e176
1
Parent(s):
0e1846b
updates
Browse files- app.py +49 -10
- tinysql_dataset_viewer.py +104 -211
- tinysql_model_demo.py +74 -52
app.py
CHANGED
|
@@ -15,7 +15,7 @@ custom_css = """
|
|
| 15 |
background-color: var(--martian-black) !important;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
/*
|
| 19 |
.tab-nav {
|
| 20 |
border-bottom: 2px solid var(--martian-gray-dark) !important;
|
| 21 |
background: var(--martian-gray-dark) !important;
|
|
@@ -24,9 +24,9 @@ custom_css = """
|
|
| 24 |
}
|
| 25 |
|
| 26 |
.tab-nav button {
|
| 27 |
-
font-size:
|
| 28 |
-
font-weight:
|
| 29 |
-
padding:
|
| 30 |
border-radius: 8px !important;
|
| 31 |
margin: 0 0.25rem !important;
|
| 32 |
transition: all 0.3s ease !important;
|
|
@@ -44,7 +44,46 @@ custom_css = """
|
|
| 44 |
box-shadow: 0 2px 8px rgba(255, 107, 74, 0.3) !important;
|
| 45 |
}
|
| 46 |
|
| 47 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
.footer {
|
| 49 |
text-align: center;
|
| 50 |
padding: 2rem 0;
|
|
@@ -97,10 +136,10 @@ with gr.Blocks(css=custom_css, title="TinySQL Demo", theme=gr.themes.Soft()) as
|
|
| 97 |
shared_schema = gr.State("")
|
| 98 |
|
| 99 |
with gr.Tabs():
|
| 100 |
-
with gr.Tab("
|
| 101 |
viewer_components = dataset_viewer(shared_instruction, shared_schema)
|
| 102 |
|
| 103 |
-
with gr.Tab("
|
| 104 |
model_components = model_demo(shared_instruction, shared_schema)
|
| 105 |
|
| 106 |
# Footer with Martian branding
|
|
@@ -111,9 +150,9 @@ with gr.Blocks(css=custom_css, title="TinySQL Demo", theme=gr.themes.Soft()) as
|
|
| 111 |
Brought to you with <span class="heart">❤️</span> from the Martian science team
|
| 112 |
</p>
|
| 113 |
<p class="footer-text" style="font-size: 0.85rem; margin-top: 1rem;">
|
| 114 |
-
<a href="https://arxiv.org/abs/2503.12730" style="color: #FF6B4A; text-decoration: none;"
|
| 115 |
-
<a href="https://github.com/withmartian/TinySQL" style="color: #FF6B4A; text-decoration: none;"
|
| 116 |
-
<a href="https://huggingface.co/collections/withmartian/tinysql-6760e92748b63fa56a6ffc9f" style="color: #FF6B4A; text-decoration: none;"
|
| 117 |
</p>
|
| 118 |
</div>
|
| 119 |
""")
|
|
|
|
| 15 |
background-color: var(--martian-black) !important;
|
| 16 |
}
|
| 17 |
|
| 18 |
+
/* Better tabs - bold, bigger, no icons */
|
| 19 |
.tab-nav {
|
| 20 |
border-bottom: 2px solid var(--martian-gray-dark) !important;
|
| 21 |
background: var(--martian-gray-dark) !important;
|
|
|
|
| 24 |
}
|
| 25 |
|
| 26 |
.tab-nav button {
|
| 27 |
+
font-size: 1.2rem !important;
|
| 28 |
+
font-weight: 700 !important;
|
| 29 |
+
padding: 1rem 2rem !important;
|
| 30 |
border-radius: 8px !important;
|
| 31 |
margin: 0 0.25rem !important;
|
| 32 |
transition: all 0.3s ease !important;
|
|
|
|
| 44 |
box-shadow: 0 2px 8px rgba(255, 107, 74, 0.3) !important;
|
| 45 |
}
|
| 46 |
|
| 47 |
+
/* Orange labels - remove all purple */
|
| 48 |
+
label, .label-wrap {
|
| 49 |
+
color: #E0E0E0 !important;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.label-wrap span {
|
| 53 |
+
background: var(--martian-orange) !important;
|
| 54 |
+
color: white !important;
|
| 55 |
+
padding: 0.35rem 0.75rem !important;
|
| 56 |
+
border-radius: 6px !important;
|
| 57 |
+
font-weight: 600 !important;
|
| 58 |
+
font-size: 0.9rem !important;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/* Orange sliders */
|
| 62 |
+
input[type="range"] {
|
| 63 |
+
background: var(--martian-gray-medium) !important;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
input[type="range"]::-webkit-slider-thumb {
|
| 67 |
+
background: var(--martian-orange) !important;
|
| 68 |
+
cursor: pointer !important;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
input[type="range"]::-moz-range-thumb {
|
| 72 |
+
background: var(--martian-orange) !important;
|
| 73 |
+
cursor: pointer !important;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
input[type="range"]::-webkit-slider-runnable-track {
|
| 77 |
+
background: linear-gradient(to right, var(--martian-orange) 0%, var(--martian-gray-light) 100%) !important;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/* Remove any purple/blue colors */
|
| 81 |
+
.primary, .secondary {
|
| 82 |
+
background: var(--martian-orange) !important;
|
| 83 |
+
border-color: var(--martian-orange) !important;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/* Footer */
|
| 87 |
.footer {
|
| 88 |
text-align: center;
|
| 89 |
padding: 2rem 0;
|
|
|
|
| 136 |
shared_schema = gr.State("")
|
| 137 |
|
| 138 |
with gr.Tabs():
|
| 139 |
+
with gr.Tab("Dataset Viewer"):
|
| 140 |
viewer_components = dataset_viewer(shared_instruction, shared_schema)
|
| 141 |
|
| 142 |
+
with gr.Tab("Model Demo"):
|
| 143 |
model_components = model_demo(shared_instruction, shared_schema)
|
| 144 |
|
| 145 |
# Footer with Martian branding
|
|
|
|
| 150 |
Brought to you with <span class="heart">❤️</span> from the Martian science team
|
| 151 |
</p>
|
| 152 |
<p class="footer-text" style="font-size: 0.85rem; margin-top: 1rem;">
|
| 153 |
+
<a href="https://arxiv.org/abs/2503.12730" style="color: #FF6B4A; text-decoration: none;">Paper</a> •
|
| 154 |
+
<a href="https://github.com/withmartian/TinySQL" style="color: #FF6B4A; text-decoration: none;">Code</a> •
|
| 155 |
+
<a href="https://huggingface.co/collections/withmartian/tinysql-6760e92748b63fa56a6ffc9f" style="color: #FF6B4A; text-decoration: none;">Dataset</a>
|
| 156 |
</p>
|
| 157 |
</div>
|
| 158 |
""")
|
tinysql_dataset_viewer.py
CHANGED
|
@@ -33,180 +33,10 @@ def filter_dataframe(df, search_query):
|
|
| 33 |
)
|
| 34 |
return df[mask]
|
| 35 |
|
| 36 |
-
# HuggingFace-style CSS
|
| 37 |
-
hf_style_css = """
|
| 38 |
-
/* HuggingFace-inspired table styling */
|
| 39 |
-
.dataframe-container {
|
| 40 |
-
border-radius: 12px !important;
|
| 41 |
-
overflow: hidden !important;
|
| 42 |
-
border: 1px solid #2A2A2A !important;
|
| 43 |
-
background: #1A1A1A !important;
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
.dataframe table {
|
| 47 |
-
border-collapse: separate !important;
|
| 48 |
-
border-spacing: 0 !important;
|
| 49 |
-
width: 100% !important;
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
.dataframe thead {
|
| 53 |
-
background: linear-gradient(135deg, #2A2A2A 0%, #3A3A3A 100%) !important;
|
| 54 |
-
position: sticky !important;
|
| 55 |
-
top: 0 !important;
|
| 56 |
-
z-index: 10 !important;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
.dataframe thead th {
|
| 60 |
-
color: #FF6B4A !important;
|
| 61 |
-
font-weight: 600 !important;
|
| 62 |
-
text-align: left !important;
|
| 63 |
-
padding: 1rem !important;
|
| 64 |
-
border-bottom: 2px solid #FF6B4A !important;
|
| 65 |
-
font-size: 0.9rem !important;
|
| 66 |
-
text-transform: uppercase !important;
|
| 67 |
-
letter-spacing: 0.5px !important;
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
.dataframe tbody tr {
|
| 71 |
-
background: #1A1A1A !important;
|
| 72 |
-
transition: all 0.2s ease !important;
|
| 73 |
-
border-bottom: 1px solid #2A2A2A !important;
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
.dataframe tbody tr:hover {
|
| 77 |
-
background: #2A2A2A !important;
|
| 78 |
-
box-shadow: 0 2px 8px rgba(255, 107, 74, 0.1) !important;
|
| 79 |
-
transform: scale(1.01) !important;
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
.dataframe tbody td {
|
| 83 |
-
padding: 0.75rem 1rem !important;
|
| 84 |
-
color: #D0D0D0 !important;
|
| 85 |
-
font-size: 0.9rem !important;
|
| 86 |
-
line-height: 1.5 !important;
|
| 87 |
-
}
|
| 88 |
-
|
| 89 |
-
.dataframe tbody tr:nth-child(even) {
|
| 90 |
-
background: #181818 !important;
|
| 91 |
-
}
|
| 92 |
-
|
| 93 |
-
.dataframe tbody tr:nth-child(even):hover {
|
| 94 |
-
background: #2A2A2A !important;
|
| 95 |
-
}
|
| 96 |
-
|
| 97 |
-
/* Cute badges for dataset types */
|
| 98 |
-
.dataset-badge {
|
| 99 |
-
display: inline-block;
|
| 100 |
-
padding: 0.25rem 0.75rem;
|
| 101 |
-
border-radius: 12px;
|
| 102 |
-
font-size: 0.8rem;
|
| 103 |
-
font-weight: 600;
|
| 104 |
-
margin: 0.25rem;
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
.badge-basic {
|
| 108 |
-
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
|
| 109 |
-
color: white;
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
.badge-medium {
|
| 113 |
-
background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
|
| 114 |
-
color: white;
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
.badge-advanced {
|
| 118 |
-
background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
|
| 119 |
-
color: white;
|
| 120 |
-
}
|
| 121 |
-
|
| 122 |
-
/* Cute info boxes */
|
| 123 |
-
.cute-info-box {
|
| 124 |
-
background: linear-gradient(135deg, #2A2A2A 0%, #3A3A3A 100%);
|
| 125 |
-
border-radius: 16px;
|
| 126 |
-
padding: 1.5rem;
|
| 127 |
-
margin: 1rem 0;
|
| 128 |
-
border: 2px solid #FF6B4A;
|
| 129 |
-
box-shadow: 0 4px 12px rgba(255, 107, 74, 0.15);
|
| 130 |
-
position: relative;
|
| 131 |
-
overflow: hidden;
|
| 132 |
-
}
|
| 133 |
-
|
| 134 |
-
.cute-info-box::before {
|
| 135 |
-
content: '';
|
| 136 |
-
position: absolute;
|
| 137 |
-
top: 0;
|
| 138 |
-
left: 0;
|
| 139 |
-
width: 4px;
|
| 140 |
-
height: 100%;
|
| 141 |
-
background: linear-gradient(180deg, #FF6B4A 0%, #FF5733 100%);
|
| 142 |
-
}
|
| 143 |
-
|
| 144 |
-
.cute-info-box h3 {
|
| 145 |
-
color: #FF6B4A;
|
| 146 |
-
font-size: 1.1rem;
|
| 147 |
-
margin-bottom: 0.5rem;
|
| 148 |
-
font-weight: 600;
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
.cute-info-box p {
|
| 152 |
-
color: #D0D0D0;
|
| 153 |
-
line-height: 1.6;
|
| 154 |
-
margin: 0;
|
| 155 |
-
}
|
| 156 |
-
|
| 157 |
-
/* Loading animation */
|
| 158 |
-
.loading {
|
| 159 |
-
display: inline-block;
|
| 160 |
-
width: 20px;
|
| 161 |
-
height: 20px;
|
| 162 |
-
border: 3px solid #3A3A3A;
|
| 163 |
-
border-top: 3px solid #FF6B4A;
|
| 164 |
-
border-radius: 50%;
|
| 165 |
-
animation: spin 1s linear infinite;
|
| 166 |
-
}
|
| 167 |
-
|
| 168 |
-
@keyframes spin {
|
| 169 |
-
0% { transform: rotate(0deg); }
|
| 170 |
-
100% { transform: rotate(360deg); }
|
| 171 |
-
}
|
| 172 |
-
|
| 173 |
-
/* Cute buttons */
|
| 174 |
-
.cute-button {
|
| 175 |
-
background: linear-gradient(135deg, #FF6B4A 0%, #FF5733 100%) !important;
|
| 176 |
-
border: none !important;
|
| 177 |
-
border-radius: 12px !important;
|
| 178 |
-
padding: 0.75rem 1.5rem !important;
|
| 179 |
-
font-weight: 600 !important;
|
| 180 |
-
color: white !important;
|
| 181 |
-
box-shadow: 0 4px 12px rgba(255, 107, 74, 0.3) !important;
|
| 182 |
-
transition: all 0.3s ease !important;
|
| 183 |
-
}
|
| 184 |
-
|
| 185 |
-
.cute-button:hover {
|
| 186 |
-
transform: translateY(-2px) !important;
|
| 187 |
-
box-shadow: 0 6px 16px rgba(255, 107, 74, 0.4) !important;
|
| 188 |
-
}
|
| 189 |
-
|
| 190 |
-
/* Search box */
|
| 191 |
-
.search-box input {
|
| 192 |
-
background: #2A2A2A !important;
|
| 193 |
-
border: 2px solid #3A3A3A !important;
|
| 194 |
-
border-radius: 12px !important;
|
| 195 |
-
padding: 0.75rem !important;
|
| 196 |
-
color: #E0E0E0 !important;
|
| 197 |
-
transition: all 0.3s ease !important;
|
| 198 |
-
}
|
| 199 |
-
|
| 200 |
-
.search-box input:focus {
|
| 201 |
-
border-color: #FF6B4A !important;
|
| 202 |
-
box-shadow: 0 0 0 3px rgba(255, 107, 74, 0.1) !important;
|
| 203 |
-
}
|
| 204 |
-
"""
|
| 205 |
-
|
| 206 |
def dataset_viewer(shared_instruction, shared_schema):
|
| 207 |
gr.HTML("""
|
| 208 |
<div style="text-align: center; padding: 2rem 1.5rem; background: linear-gradient(135deg, #2A2A2A 0%, #3A3A3A 100%); border-radius: 16px; margin-bottom: 1.5rem; box-shadow: 0 4px 12px rgba(0,0,0,0.3);">
|
| 209 |
-
<h2 style="font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; color: #FF6B4A;"
|
| 210 |
<p style="font-size: 1rem; opacity: 0.9; line-height: 1.6; color: #D0D0D0;">
|
| 211 |
Browse, search, and explore TinySQL datasets
|
| 212 |
</p>
|
|
@@ -214,15 +44,16 @@ def dataset_viewer(shared_instruction, shared_schema):
|
|
| 214 |
""")
|
| 215 |
|
| 216 |
gr.HTML("""
|
| 217 |
-
<div
|
| 218 |
-
<
|
| 219 |
-
|
|
|
|
| 220 |
</div>
|
| 221 |
""")
|
| 222 |
|
| 223 |
with gr.Row():
|
| 224 |
with gr.Column(scale=1):
|
| 225 |
-
gr.Markdown("###
|
| 226 |
|
| 227 |
dataset_dropdown = gr.Dropdown(
|
| 228 |
choices=list(DATASETS.keys()),
|
|
@@ -231,35 +62,44 @@ def dataset_viewer(shared_instruction, shared_schema):
|
|
| 231 |
info="Select complexity level"
|
| 232 |
)
|
| 233 |
|
|
|
|
| 234 |
gr.HTML("""
|
| 235 |
-
<div style="background: #2A2A2A; border-radius: 12px; padding: 1.
|
| 236 |
-
<h4 style="color: #FF6B4A; font-size: 0.
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
<
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
</div>
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
</div>
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
<
|
|
|
|
|
|
|
|
|
|
| 252 |
</div>
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
<
|
|
|
|
| 256 |
</div>
|
| 257 |
</div>
|
| 258 |
""")
|
| 259 |
|
| 260 |
-
load_btn = gr.Button("
|
| 261 |
|
| 262 |
-
gr.Markdown("###
|
| 263 |
row_selector = gr.Number(
|
| 264 |
label="Row Number",
|
| 265 |
value=0,
|
|
@@ -268,18 +108,74 @@ def dataset_viewer(shared_instruction, shared_schema):
|
|
| 268 |
info="Pick a row to test"
|
| 269 |
)
|
| 270 |
|
| 271 |
-
send_to_model_btn = gr.Button("
|
| 272 |
|
| 273 |
with gr.Column(scale=3):
|
| 274 |
-
gr.Markdown("###
|
| 275 |
|
| 276 |
search_box = gr.Textbox(
|
| 277 |
-
label="
|
| 278 |
placeholder="Search across all columns...",
|
| 279 |
-
lines=1
|
| 280 |
-
elem_classes="search-box"
|
| 281 |
)
|
| 282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
df_display = gr.Dataframe(
|
| 284 |
headers=COLUMNS,
|
| 285 |
datatype=["str", "str", "str"],
|
|
@@ -289,18 +185,15 @@ def dataset_viewer(shared_instruction, shared_schema):
|
|
| 289 |
elem_classes="dataframe-container"
|
| 290 |
)
|
| 291 |
|
| 292 |
-
stats_display = gr.Markdown(
|
| 293 |
-
"👆 Click **Load Dataset** to begin exploring",
|
| 294 |
-
elem_classes="stats-info"
|
| 295 |
-
)
|
| 296 |
|
| 297 |
df_state = gr.State(value=pd.DataFrame())
|
| 298 |
|
| 299 |
def load_and_display(dataset_name):
|
| 300 |
df = load_preview(dataset_name)
|
| 301 |
if "Error" in df.columns:
|
| 302 |
-
return df, df, "
|
| 303 |
-
stats = f"
|
| 304 |
return df, df, stats
|
| 305 |
|
| 306 |
load_btn.click(
|
|
@@ -311,12 +204,12 @@ def dataset_viewer(shared_instruction, shared_schema):
|
|
| 311 |
|
| 312 |
def search_and_display(df, query):
|
| 313 |
if df.empty:
|
| 314 |
-
return df, "
|
| 315 |
|
| 316 |
filtered_df = filter_dataframe(df, query)
|
| 317 |
-
stats = f"
|
| 318 |
if query:
|
| 319 |
-
stats += f" •
|
| 320 |
return filtered_df, stats
|
| 321 |
|
| 322 |
search_box.change(
|
|
@@ -327,13 +220,13 @@ def dataset_viewer(shared_instruction, shared_schema):
|
|
| 327 |
|
| 328 |
def send_to_model(df, row_num):
|
| 329 |
if df.empty or row_num >= len(df):
|
| 330 |
-
return "", "", "
|
| 331 |
|
| 332 |
row = df.iloc[int(row_num)]
|
| 333 |
instruction = row['english_prompt'] if 'english_prompt' in row else ""
|
| 334 |
schema = row['create_statement'] if 'create_statement' in row else ""
|
| 335 |
|
| 336 |
-
return instruction, schema, f"
|
| 337 |
|
| 338 |
send_to_model_btn.click(
|
| 339 |
fn=send_to_model,
|
|
|
|
| 33 |
)
|
| 34 |
return df[mask]
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def dataset_viewer(shared_instruction, shared_schema):
|
| 37 |
gr.HTML("""
|
| 38 |
<div style="text-align: center; padding: 2rem 1.5rem; background: linear-gradient(135deg, #2A2A2A 0%, #3A3A3A 100%); border-radius: 16px; margin-bottom: 1.5rem; box-shadow: 0 4px 12px rgba(0,0,0,0.3);">
|
| 39 |
+
<h2 style="font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; color: #FF6B4A;">Dataset Explorer</h2>
|
| 40 |
<p style="font-size: 1rem; opacity: 0.9; line-height: 1.6; color: #D0D0D0;">
|
| 41 |
Browse, search, and explore TinySQL datasets
|
| 42 |
</p>
|
|
|
|
| 44 |
""")
|
| 45 |
|
| 46 |
gr.HTML("""
|
| 47 |
+
<div style="background: linear-gradient(135deg, #2A2A2A 0%, #3A3A3A 100%); border-radius: 12px; padding: 1.5rem; margin: 1rem 0; border-left: 4px solid #FF6B4A;">
|
| 48 |
+
<p style="color: #D0D0D0; margin: 0; line-height: 1.6;">
|
| 49 |
+
<strong style="color: #FF6B4A;">Quick Start:</strong> Select a dataset, click Load Dataset, then use search to filter. Pick any row and send it to the Model Demo tab.
|
| 50 |
+
</p>
|
| 51 |
</div>
|
| 52 |
""")
|
| 53 |
|
| 54 |
with gr.Row():
|
| 55 |
with gr.Column(scale=1):
|
| 56 |
+
gr.Markdown("### Controls")
|
| 57 |
|
| 58 |
dataset_dropdown = gr.Dropdown(
|
| 59 |
choices=list(DATASETS.keys()),
|
|
|
|
| 62 |
info="Select complexity level"
|
| 63 |
)
|
| 64 |
|
| 65 |
+
# Better formatted model guide card
|
| 66 |
gr.HTML("""
|
| 67 |
+
<div style="background: #2A2A2A; border-radius: 12px; padding: 1.5rem; margin: 1.5rem 0; border: 1px solid #3A3A3A;">
|
| 68 |
+
<h4 style="color: #FF6B4A; font-size: 1rem; margin: 0 0 1.25rem 0; font-weight: 700; border-bottom: 2px solid #3A3A3A; padding-bottom: 0.75rem;">Dataset Complexity Levels</h4>
|
| 69 |
+
|
| 70 |
+
<div style="margin-bottom: 1.5rem;">
|
| 71 |
+
<div style="color: #4CAF50; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.5rem;">Basic Level</div>
|
| 72 |
+
<div style="margin-left: 1rem; color: #999; font-size: 0.85rem; line-height: 1.8;">
|
| 73 |
+
<div><strong style="color: #D0D0D0;">CS1:</strong> Basic SELECT-FROM queries</div>
|
| 74 |
+
<div><strong style="color: #D0D0D0;">CS2:</strong> Adds ORDER BY clauses</div>
|
| 75 |
+
</div>
|
| 76 |
</div>
|
| 77 |
+
|
| 78 |
+
<div style="margin-bottom: 1.5rem;">
|
| 79 |
+
<div style="color: #FF9800; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.5rem;">Intermediate Level</div>
|
| 80 |
+
<div style="margin-left: 1rem; color: #999; font-size: 0.85rem; line-height: 1.8;">
|
| 81 |
+
<div><strong style="color: #D0D0D0;">CS3:</strong> Aggregations (COUNT, SUM, AVG)</div>
|
| 82 |
+
<div><strong style="color: #D0D0D0;">CS4:</strong> Adds WHERE filters</div>
|
| 83 |
+
</div>
|
| 84 |
</div>
|
| 85 |
+
|
| 86 |
+
<div>
|
| 87 |
+
<div style="color: #f44336; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.5rem;">Advanced Level</div>
|
| 88 |
+
<div style="margin-left: 1rem; color: #999; font-size: 0.85rem; line-height: 1.8;">
|
| 89 |
+
<div><strong style="color: #D0D0D0;">CS5:</strong> Multi-table JOINs</div>
|
| 90 |
+
</div>
|
| 91 |
</div>
|
| 92 |
+
|
| 93 |
+
<div style="margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid #3A3A3A;">
|
| 94 |
+
<div style="color: #FF6B4A; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem;">Synonym Variants</div>
|
| 95 |
+
<div style="color: #999; font-size: 0.85rem; line-height: 1.6;">Natural language variations with semantic mappings</div>
|
| 96 |
</div>
|
| 97 |
</div>
|
| 98 |
""")
|
| 99 |
|
| 100 |
+
load_btn = gr.Button("Load Dataset", variant="primary", size="lg")
|
| 101 |
|
| 102 |
+
gr.Markdown("### Test Example")
|
| 103 |
row_selector = gr.Number(
|
| 104 |
label="Row Number",
|
| 105 |
value=0,
|
|
|
|
| 108 |
info="Pick a row to test"
|
| 109 |
)
|
| 110 |
|
| 111 |
+
send_to_model_btn = gr.Button("Run in Model Demo", variant="primary")
|
| 112 |
|
| 113 |
with gr.Column(scale=3):
|
| 114 |
+
gr.Markdown("### Dataset Preview")
|
| 115 |
|
| 116 |
search_box = gr.Textbox(
|
| 117 |
+
label="Search",
|
| 118 |
placeholder="Search across all columns...",
|
| 119 |
+
lines=1
|
|
|
|
| 120 |
)
|
| 121 |
|
| 122 |
+
# HuggingFace-style table
|
| 123 |
+
gr.HTML("""
|
| 124 |
+
<style>
|
| 125 |
+
/* True HuggingFace-style table */
|
| 126 |
+
.dataframe-container {
|
| 127 |
+
border-radius: 8px !important;
|
| 128 |
+
overflow: hidden !important;
|
| 129 |
+
border: 1px solid #374151 !important;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
.dataframe table {
|
| 133 |
+
border-collapse: collapse !important;
|
| 134 |
+
width: 100% !important;
|
| 135 |
+
font-size: 0.875rem !important;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.dataframe thead {
|
| 139 |
+
background: #1f2937 !important;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.dataframe thead th {
|
| 143 |
+
color: #9ca3af !important;
|
| 144 |
+
font-weight: 600 !important;
|
| 145 |
+
text-align: left !important;
|
| 146 |
+
padding: 0.75rem 1rem !important;
|
| 147 |
+
border-bottom: 1px solid #374151 !important;
|
| 148 |
+
font-size: 0.75rem !important;
|
| 149 |
+
text-transform: uppercase !important;
|
| 150 |
+
letter-spacing: 0.05em !important;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
.dataframe tbody tr {
|
| 154 |
+
background: #111827 !important;
|
| 155 |
+
border-bottom: 1px solid #1f2937 !important;
|
| 156 |
+
transition: background-color 0.15s ease !important;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
.dataframe tbody tr:hover {
|
| 160 |
+
background: #1f2937 !important;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
.dataframe tbody td {
|
| 164 |
+
padding: 0.75rem 1rem !important;
|
| 165 |
+
color: #d1d5db !important;
|
| 166 |
+
font-size: 0.875rem !important;
|
| 167 |
+
line-height: 1.5 !important;
|
| 168 |
+
max-width: 400px !important;
|
| 169 |
+
overflow: hidden !important;
|
| 170 |
+
text-overflow: ellipsis !important;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.dataframe tbody tr:last-child {
|
| 174 |
+
border-bottom: none !important;
|
| 175 |
+
}
|
| 176 |
+
</style>
|
| 177 |
+
""")
|
| 178 |
+
|
| 179 |
df_display = gr.Dataframe(
|
| 180 |
headers=COLUMNS,
|
| 181 |
datatype=["str", "str", "str"],
|
|
|
|
| 185 |
elem_classes="dataframe-container"
|
| 186 |
)
|
| 187 |
|
| 188 |
+
stats_display = gr.Markdown("Click **Load Dataset** to begin exploring")
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
df_state = gr.State(value=pd.DataFrame())
|
| 191 |
|
| 192 |
def load_and_display(dataset_name):
|
| 193 |
df = load_preview(dataset_name)
|
| 194 |
if "Error" in df.columns:
|
| 195 |
+
return df, df, "Error loading dataset"
|
| 196 |
+
stats = f"**Loaded {len(df)} rows** • Columns: {', '.join(COLUMNS)}"
|
| 197 |
return df, df, stats
|
| 198 |
|
| 199 |
load_btn.click(
|
|
|
|
| 204 |
|
| 205 |
def search_and_display(df, query):
|
| 206 |
if df.empty:
|
| 207 |
+
return df, "Load a dataset first"
|
| 208 |
|
| 209 |
filtered_df = filter_dataframe(df, query)
|
| 210 |
+
stats = f"**Showing {len(filtered_df)} of {len(df)} rows**"
|
| 211 |
if query:
|
| 212 |
+
stats += f" • Search: '{query}'"
|
| 213 |
return filtered_df, stats
|
| 214 |
|
| 215 |
search_box.change(
|
|
|
|
| 220 |
|
| 221 |
def send_to_model(df, row_num):
|
| 222 |
if df.empty or row_num >= len(df):
|
| 223 |
+
return "", "", "Invalid row or no data loaded"
|
| 224 |
|
| 225 |
row = df.iloc[int(row_num)]
|
| 226 |
instruction = row['english_prompt'] if 'english_prompt' in row else ""
|
| 227 |
schema = row['create_statement'] if 'create_statement' in row else ""
|
| 228 |
|
| 229 |
+
return instruction, schema, f"**Row {row_num} loaded!** Switch to Model Demo tab"
|
| 230 |
|
| 231 |
send_to_model_btn.click(
|
| 232 |
fn=send_to_model,
|
tinysql_model_demo.py
CHANGED
|
@@ -2,7 +2,6 @@ import gradio as gr
|
|
| 2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
import torch
|
| 4 |
|
| 5 |
-
# Model configurations
|
| 6 |
MODELS = {
|
| 7 |
"BM1_CS1_Syn (33M)": "withmartian/sql_interp_bm1_cs1_experiment_1.10",
|
| 8 |
"BM1_CS2_Syn (33M)": "withmartian/sql_interp_bm1_cs2_experiment_2.10",
|
|
@@ -62,39 +61,30 @@ def generate_sql(model_name, instruction, schema, max_length=256, temperature=0.
|
|
| 62 |
except Exception as e:
|
| 63 |
return f"Error: {str(e)}"
|
| 64 |
|
|
|
|
| 65 |
examples = [
|
| 66 |
-
[
|
| 67 |
-
"BM1_CS1_Syn (33M)",
|
| 68 |
-
"Show me the name and salary from employees",
|
| 69 |
-
"CREATE TABLE employees (name VARCHAR(100), salary INT, department VARCHAR(100))"
|
| 70 |
-
],
|
| 71 |
[
|
| 72 |
"BM2_CS2_Syn (0.5B)",
|
| 73 |
"List worker earnings from highest to lowest",
|
| 74 |
"CREATE TABLE employees (name VARCHAR(100), salary INT, department VARCHAR(100))"
|
| 75 |
],
|
| 76 |
-
[
|
| 77 |
-
"BM3_CS3_Syn (1B)",
|
| 78 |
-
"Count how many employees in each department",
|
| 79 |
-
"CREATE TABLE employees (name VARCHAR(100), salary INT, department VARCHAR(100))"
|
| 80 |
-
],
|
| 81 |
]
|
| 82 |
|
| 83 |
def model_demo(shared_instruction, shared_schema):
|
| 84 |
-
"""Model demo component that can receive examples from dataset viewer"""
|
| 85 |
-
|
| 86 |
gr.HTML("""
|
| 87 |
-
<div style="text-align: center; padding:
|
| 88 |
-
<
|
| 89 |
-
<p style="font-size:
|
| 90 |
-
Transform natural language into SQL
|
| 91 |
</p>
|
| 92 |
</div>
|
| 93 |
""")
|
| 94 |
|
| 95 |
gr.HTML("""
|
| 96 |
-
<div style="background: #3A3A3A; border-radius: 12px; padding: 1.5rem; margin:
|
| 97 |
-
<
|
|
|
|
|
|
|
| 98 |
</div>
|
| 99 |
""")
|
| 100 |
|
|
@@ -105,51 +95,87 @@ def model_demo(shared_instruction, shared_schema):
|
|
| 105 |
choices=list(MODELS.keys()),
|
| 106 |
value="BM2_CS2_Syn (0.5B)",
|
| 107 |
label="Model Selection",
|
| 108 |
-
info="Larger models = better accuracy
|
| 109 |
)
|
|
|
|
|
|
|
| 110 |
gr.HTML("""
|
| 111 |
-
<div style="background: #
|
| 112 |
-
<
|
| 113 |
-
|
| 114 |
-
<
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
</div>
|
| 122 |
""")
|
| 123 |
|
| 124 |
with gr.Column(scale=2):
|
| 125 |
gr.Markdown("### Your Query")
|
| 126 |
instruction = gr.Textbox(
|
| 127 |
-
label="
|
| 128 |
-
placeholder="e.g., Find all employees earning more than
|
| 129 |
-
lines=2
|
| 130 |
-
value=""
|
| 131 |
)
|
| 132 |
-
|
|
|
|
|
|
|
| 133 |
label="Database Schema",
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
)
|
| 138 |
|
| 139 |
with gr.Row():
|
| 140 |
-
max_length = gr.Slider(64, 512, value=256, step=32, label="Max Length")
|
| 141 |
-
temperature = gr.Slider(0.0, 1.0, value=0.1, step=0.1, label="Temperature")
|
| 142 |
|
| 143 |
generate_btn = gr.Button("Generate SQL", variant="primary", size="lg")
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
gr.Examples(examples=examples, inputs=[model_dropdown, instruction, schema])
|
| 148 |
|
| 149 |
-
|
| 150 |
-
def update_from_shared(shared_inst, shared_sch):
|
| 151 |
-
return shared_inst if shared_inst else "", shared_sch if shared_sch else ""
|
| 152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
shared_instruction.change(
|
| 154 |
fn=lambda x: x,
|
| 155 |
inputs=shared_instruction,
|
|
@@ -168,8 +194,4 @@ def model_demo(shared_instruction, shared_schema):
|
|
| 168 |
outputs=output
|
| 169 |
)
|
| 170 |
|
| 171 |
-
return {
|
| 172 |
-
'instruction': instruction,
|
| 173 |
-
'schema': schema,
|
| 174 |
-
'output': output
|
| 175 |
-
}
|
|
|
|
| 2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
import torch
|
| 4 |
|
|
|
|
| 5 |
MODELS = {
|
| 6 |
"BM1_CS1_Syn (33M)": "withmartian/sql_interp_bm1_cs1_experiment_1.10",
|
| 7 |
"BM1_CS2_Syn (33M)": "withmartian/sql_interp_bm1_cs2_experiment_2.10",
|
|
|
|
| 61 |
except Exception as e:
|
| 62 |
return f"Error: {str(e)}"
|
| 63 |
|
| 64 |
+
# Only ONE example
|
| 65 |
examples = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
[
|
| 67 |
"BM2_CS2_Syn (0.5B)",
|
| 68 |
"List worker earnings from highest to lowest",
|
| 69 |
"CREATE TABLE employees (name VARCHAR(100), salary INT, department VARCHAR(100))"
|
| 70 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
]
|
| 72 |
|
| 73 |
def model_demo(shared_instruction, shared_schema):
|
|
|
|
|
|
|
| 74 |
gr.HTML("""
|
| 75 |
+
<div style="text-align: center; padding: 2rem; background: linear-gradient(135deg, #3A3A3A 0%, #4A4A4A 100%); border-radius: 16px; margin-bottom: 1.5rem;">
|
| 76 |
+
<h2 style="font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; color: white;">Interactive SQL Generation</h2>
|
| 77 |
+
<p style="font-size: 1rem; opacity: 0.9; line-height: 1.6; color: #D0D0D0;">
|
| 78 |
+
Transform natural language into SQL using <span style="color: #FF6B4A; font-weight: 600;">mechanistically interpretable</span> models
|
| 79 |
</p>
|
| 80 |
</div>
|
| 81 |
""")
|
| 82 |
|
| 83 |
gr.HTML("""
|
| 84 |
+
<div style="background: linear-gradient(135deg, #2A2A2A 0%, #3A3A3A 100%); border-radius: 12px; padding: 1.5rem; margin: 1rem 0; border-left: 4px solid #FF6B4A;">
|
| 85 |
+
<p style="color: #D0D0D0; margin: 0; line-height: 1.6;">
|
| 86 |
+
<strong style="color: #FF6B4A;">How it works:</strong> Select a model, describe your query in plain English, and watch the model generate SQL.
|
| 87 |
+
</p>
|
| 88 |
</div>
|
| 89 |
""")
|
| 90 |
|
|
|
|
| 95 |
choices=list(MODELS.keys()),
|
| 96 |
value="BM2_CS2_Syn (0.5B)",
|
| 97 |
label="Model Selection",
|
| 98 |
+
info="Larger models = better accuracy"
|
| 99 |
)
|
| 100 |
+
|
| 101 |
+
# Better formatted guide
|
| 102 |
gr.HTML("""
|
| 103 |
+
<div style="background: #2A2A2A; border-radius: 12px; padding: 1.5rem; margin: 1.5rem 0; border: 1px solid #3A3A3A;">
|
| 104 |
+
<h4 style="color: #FF6B4A; font-size: 1rem; margin: 0 0 1.25rem 0; font-weight: 700; border-bottom: 2px solid #3A3A3A; padding-bottom: 0.75rem;">Model Guide</h4>
|
| 105 |
+
|
| 106 |
+
<div style="margin-bottom: 1rem;">
|
| 107 |
+
<div style="color: #4CAF50; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem;">BM1 (33M parameters)</div>
|
| 108 |
+
<div style="color: #999; font-size: 0.85rem; margin-left: 1rem;">Lightning fast, ideal for simple queries</div>
|
| 109 |
+
</div>
|
| 110 |
+
|
| 111 |
+
<div style="margin-bottom: 1rem;">
|
| 112 |
+
<div style="color: #FF9800; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem;">BM2 (0.5B parameters)</div>
|
| 113 |
+
<div style="color: #999; font-size: 0.85rem; margin-left: 1rem;">Balanced performance and speed</div>
|
| 114 |
+
</div>
|
| 115 |
+
|
| 116 |
+
<div style="margin-bottom: 1.25rem;">
|
| 117 |
+
<div style="color: #f44336; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem;">BM3 (1B parameters)</div>
|
| 118 |
+
<div style="color: #999; font-size: 0.85rem; margin-left: 1rem;">Most accurate for complex queries</div>
|
| 119 |
+
</div>
|
| 120 |
+
|
| 121 |
+
<div style="padding-top: 1rem; border-top: 1px solid #3A3A3A;">
|
| 122 |
+
<div style="color: #FF6B4A; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.75rem;">Dataset Complexity</div>
|
| 123 |
+
<div style="color: #999; font-size: 0.85rem; line-height: 1.8;">
|
| 124 |
+
<div><strong style="color: #D0D0D0;">CS1:</strong> Basic SELECT-FROM</div>
|
| 125 |
+
<div><strong style="color: #D0D0D0;">CS2:</strong> Adds ORDER BY</div>
|
| 126 |
+
<div><strong style="color: #D0D0D0;">CS3:</strong> Aggregations</div>
|
| 127 |
+
<div><strong style="color: #D0D0D0;">CS4:</strong> WHERE filters</div>
|
| 128 |
+
<div><strong style="color: #D0D0D0;">CS5:</strong> Multi-table JOINs</div>
|
| 129 |
+
</div>
|
| 130 |
+
</div>
|
| 131 |
</div>
|
| 132 |
""")
|
| 133 |
|
| 134 |
with gr.Column(scale=2):
|
| 135 |
gr.Markdown("### Your Query")
|
| 136 |
instruction = gr.Textbox(
|
| 137 |
+
label="Natural Language Query",
|
| 138 |
+
placeholder="e.g., Find all employees earning more than 50000 sorted by name",
|
| 139 |
+
lines=2
|
|
|
|
| 140 |
)
|
| 141 |
+
|
| 142 |
+
# Database schema as Code (SQL formatted)
|
| 143 |
+
schema = gr.Code(
|
| 144 |
label="Database Schema",
|
| 145 |
+
language="sql",
|
| 146 |
+
value="CREATE TABLE employees (name VARCHAR(100), salary INT, department VARCHAR(100))",
|
| 147 |
+
lines=3
|
| 148 |
)
|
| 149 |
|
| 150 |
with gr.Row():
|
| 151 |
+
max_length = gr.Slider(64, 512, value=256, step=32, label="Max Length", info="Token limit")
|
| 152 |
+
temperature = gr.Slider(0.0, 1.0, value=0.1, step=0.1, label="Temperature", info="Creativity level")
|
| 153 |
|
| 154 |
generate_btn = gr.Button("Generate SQL", variant="primary", size="lg")
|
| 155 |
+
|
| 156 |
+
# Output as Code (SQL formatted)
|
| 157 |
+
output = gr.Code(label="Generated SQL Query", language="sql", lines=6)
|
|
|
|
| 158 |
|
| 159 |
+
gr.Markdown("### Example Query")
|
|
|
|
|
|
|
| 160 |
|
| 161 |
+
# Custom examples with 2-line schema display
|
| 162 |
+
gr.HTML("""
|
| 163 |
+
<div style="background: #2A2A2A; border-radius: 12px; padding: 1.5rem; margin: 1rem 0; border: 1px solid #3A3A3A;">
|
| 164 |
+
<div style="margin-bottom: 0.75rem;">
|
| 165 |
+
<strong style="color: #FF6B4A;">Model:</strong> <span style="color: #D0D0D0;">BM2_CS2_Syn (0.5B)</span>
|
| 166 |
+
</div>
|
| 167 |
+
<div style="margin-bottom: 0.75rem;">
|
| 168 |
+
<strong style="color: #FF6B4A;">Query:</strong> <span style="color: #D0D0D0;">List worker earnings from highest to lowest</span>
|
| 169 |
+
</div>
|
| 170 |
+
<div>
|
| 171 |
+
<strong style="color: #FF6B4A;">Schema:</strong>
|
| 172 |
+
<pre style="background: #1A1A1A; padding: 0.75rem; border-radius: 6px; margin-top: 0.5rem; color: #D0D0D0; font-size: 0.85rem; line-height: 1.5;">CREATE TABLE employees (
|
| 173 |
+
name VARCHAR(100), salary INT, department VARCHAR(100)
|
| 174 |
+
)</pre>
|
| 175 |
+
</div>
|
| 176 |
+
</div>
|
| 177 |
+
""")
|
| 178 |
+
|
| 179 |
shared_instruction.change(
|
| 180 |
fn=lambda x: x,
|
| 181 |
inputs=shared_instruction,
|
|
|
|
| 194 |
outputs=output
|
| 195 |
)
|
| 196 |
|
| 197 |
+
return {'instruction': instruction, 'schema': schema, 'output': output}
|
|
|
|
|
|
|
|
|
|
|
|