abir-hr196 commited on
Commit
a6c02ed
·
1 Parent(s): 0f515d8

updates_logo

Browse files
Files changed (5) hide show
  1. .DS_Store +0 -0
  2. app.py +51 -29
  3. static/.DS_Store +0 -0
  4. static/images/martian_logo.jpg +0 -0
  5. tinysql_model_demo.py +18 -16
.DS_Store ADDED
Binary file (6.15 kB). View file
 
app.py CHANGED
@@ -72,43 +72,63 @@ select:focus, input:focus, textarea:focus {
72
  box-shadow: 0 0 0 2px rgba(255, 107, 74, 0.2) !important;
73
  }
74
 
75
- /* Orange sliders - selected area is orange */
76
  input[type="range"] {
77
- background: transparent !important;
 
 
 
78
  }
79
 
80
- input[type="range"]::-webkit-slider-thumb {
81
- background: var(--martian-orange) !important;
82
- cursor: pointer !important;
83
- width: 16px !important;
84
- height: 16px !important;
85
- border-radius: 50% !important;
86
  }
87
 
88
- input[type="range"]::-moz-range-thumb {
89
- background: var(--martian-orange) !important;
90
- cursor: pointer !important;
91
- width: 16px !important;
92
- height: 16px !important;
93
- border-radius: 50% !important;
 
 
 
 
94
  }
95
 
96
- input[type="range"]::-webkit-slider-runnable-track {
97
- background: linear-gradient(to right, var(--martian-orange) 0%, var(--martian-orange) var(--value, 50%), #3A3A3A var(--value, 50%), #3A3A3A 100%) !important;
98
- height: 4px !important;
99
- border-radius: 2px !important;
100
  }
101
 
102
- input[type="range"]::-moz-range-track {
103
- background: #3A3A3A !important;
104
- height: 4px !important;
105
- border-radius: 2px !important;
 
 
 
 
106
  }
107
 
108
  input[type="range"]::-moz-range-progress {
109
- background: var(--martian-orange) !important;
110
- height: 4px !important;
111
- border-radius: 2px !important;
 
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
  /* Remove any purple/blue colors */
@@ -132,10 +152,12 @@ button {
132
  }
133
 
134
  .footer-logo {
135
- width: 120px;
136
- margin-bottom: 1rem;
 
137
  opacity: 0.9;
138
  transition: opacity 0.3s ease;
 
139
  }
140
 
141
  .footer-logo:hover {
@@ -227,14 +249,14 @@ with gr.Blocks(css=custom_css, title="TinySQL Demo", theme=gr.themes.Soft()) as
227
  # Footer with Martian branding
228
  gr.HTML("""
229
  <div class="footer">
230
- <img src="https://withmartian.com/logo.png" alt="Martian" class="footer-logo" onerror="this.style.display='none'">
231
  <p class="footer-text">
232
  Brought to you with <span class="heart">❤️</span> from the Martian science team
233
  </p>
 
234
  <p class="footer-text" style="font-size: 0.85rem; margin-top: 1rem;">
235
  <a href="https://arxiv.org/abs/2503.12730" style="color: #FF6B4A; text-decoration: none;">Paper</a> •
236
  <a href="https://github.com/withmartian/TinySQL" style="color: #FF6B4A; text-decoration: none;">Code</a> •
237
- <a href="https://huggingface.co/collections/withmartian/tinysql-tinysql-6760e92748b63fa56a6ffc9f" style="color: #FF6B4A; text-decoration: none;">Dataset</a>
238
  </p>
239
  </div>
240
  """)
 
72
  box-shadow: 0 0 0 2px rgba(255, 107, 74, 0.2) !important;
73
  }
74
 
75
+ /* Orange sliders - properly following thumb position */
76
  input[type="range"] {
77
+ -webkit-appearance: none;
78
+ appearance: none;
79
+ background: transparent;
80
+ cursor: pointer;
81
  }
82
 
83
+ input[type="range"]::-webkit-slider-track {
84
+ background: #3A3A3A;
85
+ height: 6px;
86
+ border-radius: 3px;
 
 
87
  }
88
 
89
+ input[type="range"]::-webkit-slider-thumb {
90
+ -webkit-appearance: none;
91
+ appearance: none;
92
+ background: var(--martian-orange);
93
+ height: 18px;
94
+ width: 18px;
95
+ border-radius: 50%;
96
+ cursor: pointer;
97
+ margin-top: -6px;
98
+ box-shadow: 0 2px 4px rgba(255, 107, 74, 0.3);
99
  }
100
 
101
+ input[type="range"]::-moz-range-track {
102
+ background: #3A3A3A;
103
+ height: 6px;
104
+ border-radius: 3px;
105
  }
106
 
107
+ input[type="range"]::-moz-range-thumb {
108
+ background: var(--martian-orange);
109
+ height: 18px;
110
+ width: 18px;
111
+ border-radius: 50%;
112
+ cursor: pointer;
113
+ border: none;
114
+ box-shadow: 0 2px 4px rgba(255, 107, 74, 0.3);
115
  }
116
 
117
  input[type="range"]::-moz-range-progress {
118
+ background: var(--martian-orange);
119
+ height: 6px;
120
+ border-radius: 3px;
121
+ }
122
+
123
+ /* For Webkit browsers, use a gradient workaround */
124
+ input[type="range"]::-webkit-slider-runnable-track {
125
+ background: linear-gradient(to right,
126
+ var(--martian-orange) 0%,
127
+ var(--martian-orange) var(--value, 0%),
128
+ #3A3A3A var(--value, 0%),
129
+ #3A3A3A 100%);
130
+ height: 6px;
131
+ border-radius: 3px;
132
  }
133
 
134
  /* Remove any purple/blue colors */
 
152
  }
153
 
154
  .footer-logo {
155
+ width: 80px !important;
156
+ height: auto !important;
157
+ margin: 1rem auto !important;
158
  opacity: 0.9;
159
  transition: opacity 0.3s ease;
160
+ display: block;
161
  }
162
 
163
  .footer-logo:hover {
 
249
  # Footer with Martian branding
250
  gr.HTML("""
251
  <div class="footer">
 
252
  <p class="footer-text">
253
  Brought to you with <span class="heart">❤️</span> from the Martian science team
254
  </p>
255
+ <img src="file/static/images/martian_logo.jpg" alt="Martian" class="footer-logo" style="width: 80px; margin: 1rem auto; display: block;">
256
  <p class="footer-text" style="font-size: 0.85rem; margin-top: 1rem;">
257
  <a href="https://arxiv.org/abs/2503.12730" style="color: #FF6B4A; text-decoration: none;">Paper</a> •
258
  <a href="https://github.com/withmartian/TinySQL" style="color: #FF6B4A; text-decoration: none;">Code</a> •
259
+ <a href="https://huggingface.co/collections/withmartian/tinysql-6760e92748b63fa56a6ffc9f" style="color: #FF6B4A; text-decoration: none;">Dataset</a>
260
  </p>
261
  </div>
262
  """)
static/.DS_Store ADDED
Binary file (6.15 kB). View file
 
static/images/martian_logo.jpg ADDED
tinysql_model_demo.py CHANGED
@@ -30,7 +30,7 @@ def load_model(model_name):
30
  model_cache[model_name] = (tokenizer, model)
31
  return model_cache[model_name]
32
 
33
- def generate_sql(model_name, instruction, schema, max_length=256, temperature=0.7):
34
  if not model_name or not instruction or not schema:
35
  return "Please fill in all fields and select a model"
36
 
@@ -46,7 +46,7 @@ def generate_sql(model_name, instruction, schema, max_length=256, temperature=0.
46
  outputs = model.generate(
47
  **inputs,
48
  max_length=max_length,
49
- temperature=temperature,
50
  do_sample=temperature > 0,
51
  pad_token_id=tokenizer.eos_token_id
52
  )
@@ -89,7 +89,6 @@ def model_demo(shared_instruction, shared_schema):
89
  info="Larger models = better accuracy"
90
  )
91
 
92
- # Better formatted guide with base models
93
  gr.HTML("""
94
  <div style="background: #2A2A2A; border-radius: 12px; padding: 1.5rem; margin: 1.5rem 0; border: 1px solid #3A3A3A;">
95
  <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>
@@ -125,14 +124,13 @@ def model_demo(shared_instruction, shared_schema):
125
  with gr.Column(scale=2):
126
  gr.Markdown("### Your Query")
127
 
128
- # Query as Textbox styled like a code box
129
  instruction = gr.Textbox(
130
  label="Natural Language Query",
131
  placeholder="e.g., Find all employees earning more than 50000 sorted by name",
132
  lines=2,
133
  value=""
134
  )
135
- # Database schema as Code (SQL formatted)
136
  schema = gr.Code(
137
  label="Database Schema",
138
  language="sql",
@@ -142,29 +140,33 @@ def model_demo(shared_instruction, shared_schema):
142
 
143
  with gr.Row():
144
  max_length = gr.Slider(64, 512, value=256, step=32, label="Max Length", info="Token limit")
145
- temperature = gr.Slider(0.0, 1.0, value=0.1, step=0.1, label="Temperature", info="Creativity level")
146
 
147
  generate_btn = gr.Button("Generate SQL", variant="primary", size="lg")
148
 
149
- # Output as Code (SQL formatted)
150
  output = gr.Code(label="Generated SQL Query", language="sql", lines=6)
151
 
152
  gr.Markdown("### Example Query")
153
 
154
- # Custom example with query in styled box
155
  gr.HTML("""
156
  <div style="background: #2A2A2A; border-radius: 12px; padding: 1.5rem; margin: 1rem 0; border: 1px solid #3A3A3A;">
157
- <div style="margin-bottom: 0.75rem;">
158
- <strong style="color: #FF6B4A;">Model:</strong> <span style="color: #D0D0D0;">BM2_CS2_Syn (0.5B)</span>
 
159
  </div>
160
- <div style="margin-bottom: 0.75rem;">
161
- <strong style="color: #FF6B4A;">Query:</strong>
162
- <pre style="background: #1A1A1A; padding: 0.75rem; border-radius: 6px; margin-top: 0.5rem; color: #D0D0D0; font-size: 0.85rem; line-height: 1.5;">List worker earnings from highest to lowest</pre>
 
163
  </div>
 
164
  <div>
165
- <strong style="color: #FF6B4A;">Schema:</strong>
166
- <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 (
167
- name VARCHAR(100), salary INT, department VARCHAR(100)
 
 
168
  )</pre>
169
  </div>
170
  </div>
 
30
  model_cache[model_name] = (tokenizer, model)
31
  return model_cache[model_name]
32
 
33
+ def generate_sql(model_name, instruction, schema, max_length=256, temperature=0.0):
34
  if not model_name or not instruction or not schema:
35
  return "Please fill in all fields and select a model"
36
 
 
46
  outputs = model.generate(
47
  **inputs,
48
  max_length=max_length,
49
+ temperature=temperature if temperature > 0 else 1.0,
50
  do_sample=temperature > 0,
51
  pad_token_id=tokenizer.eos_token_id
52
  )
 
89
  info="Larger models = better accuracy"
90
  )
91
 
 
92
  gr.HTML("""
93
  <div style="background: #2A2A2A; border-radius: 12px; padding: 1.5rem; margin: 1.5rem 0; border: 1px solid #3A3A3A;">
94
  <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>
 
124
  with gr.Column(scale=2):
125
  gr.Markdown("### Your Query")
126
 
 
127
  instruction = gr.Textbox(
128
  label="Natural Language Query",
129
  placeholder="e.g., Find all employees earning more than 50000 sorted by name",
130
  lines=2,
131
  value=""
132
  )
133
+
134
  schema = gr.Code(
135
  label="Database Schema",
136
  language="sql",
 
140
 
141
  with gr.Row():
142
  max_length = gr.Slider(64, 512, value=256, step=32, label="Max Length", info="Token limit")
143
+ temperature = gr.Slider(0.0, 1.0, value=0.0, step=0.1, label="Temperature", info="Creativity level (0 = deterministic)")
144
 
145
  generate_btn = gr.Button("Generate SQL", variant="primary", size="lg")
146
 
 
147
  output = gr.Code(label="Generated SQL Query", language="sql", lines=6)
148
 
149
  gr.Markdown("### Example Query")
150
 
151
+ # Better styled example with proper font
152
  gr.HTML("""
153
  <div style="background: #2A2A2A; border-radius: 12px; padding: 1.5rem; margin: 1rem 0; border: 1px solid #3A3A3A;">
154
+ <div style="margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid #3A3A3A;">
155
+ <div style="color: #FF6B4A; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem;">Model</div>
156
+ <div style="background: #1A1A1A; padding: 0.75rem; border-radius: 6px; color: #D0D0D0; font-family: 'Inter', sans-serif; font-size: 0.9rem;">BM2_CS2_Syn (0.5B)</div>
157
  </div>
158
+
159
+ <div style="margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid #3A3A3A;">
160
+ <div style="color: #FF6B4A; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem;">Natural Language Query</div>
161
+ <div style="background: #1A1A1A; padding: 0.75rem; border-radius: 6px; color: #D0D0D0; font-family: 'Inter', sans-serif; font-size: 0.9rem; line-height: 1.5;">List worker earnings from highest to lowest</div>
162
  </div>
163
+
164
  <div>
165
+ <div style="color: #FF6B4A; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem;">Database Schema</div>
166
+ <pre style="background: #1A1A1A; padding: 0.75rem; border-radius: 6px; margin: 0; color: #D0D0D0; font-family: 'Monaco', 'Courier New', monospace; font-size: 0.85rem; line-height: 1.5; overflow-x: auto;">CREATE TABLE employees (
167
+ name VARCHAR(100),
168
+ salary INT,
169
+ department VARCHAR(100)
170
  )</pre>
171
  </div>
172
  </div>