Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -135,33 +135,96 @@ examples = [
|
|
| 135 |
["How often do you use a smartphone or tablet?"],
|
| 136 |
]
|
| 137 |
|
| 138 |
-
# Custom CSS for Sikt branding
|
| 139 |
custom_css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
.gradio-container {
|
| 141 |
-
font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, sans-serif;
|
| 142 |
}
|
| 143 |
-
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
}
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
| 151 |
}
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
| 155 |
}
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
}
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
| 162 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
footer {
|
| 164 |
-
background-color:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
}
|
| 166 |
"""
|
| 167 |
|
|
@@ -174,55 +237,78 @@ demo = gr.Interface(
|
|
| 174 |
label="Survey Question"
|
| 175 |
),
|
| 176 |
outputs=gr.Markdown(label="Classification Result"),
|
| 177 |
-
title="
|
| 178 |
description="""
|
| 179 |
-
<div
|
| 180 |
-
<
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
</div>
|
| 187 |
</div>
|
| 188 |
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
|
|
|
|
|
|
|
|
|
| 192 |
""",
|
| 193 |
examples=examples,
|
| 194 |
article="""
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
[Sikt](https://sikt.no) – Norwegian Agency for Shared Services in Education and Research
|
| 217 |
-
provides digital infrastructure and services for research and education in Norway.
|
| 218 |
|
| 219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
|
| 221 |
-
<div style="
|
| 222 |
-
<
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
</p>
|
| 225 |
</div>
|
|
|
|
|
|
|
| 226 |
""",
|
| 227 |
theme=gr.themes.Soft(
|
| 228 |
primary_hue="red",
|
|
|
|
| 135 |
["How often do you use a smartphone or tablet?"],
|
| 136 |
]
|
| 137 |
|
| 138 |
+
# Custom CSS for Sikt branding using design tokens
|
| 139 |
custom_css = """
|
| 140 |
+
:root {
|
| 141 |
+
/* Sikt Design Tokens */
|
| 142 |
+
--sds-color-text-primary: #1a1a1a;
|
| 143 |
+
--sds-color-text-secondary: #331c6c;
|
| 144 |
+
--sds-color-interaction-primary: #7d5da6;
|
| 145 |
+
--sds-color-interaction-primary-hover: #6b4d94;
|
| 146 |
+
--sds-color-layout-background-default: #ffffff;
|
| 147 |
+
--sds-color-layout-background-subtle: #f3f1fe;
|
| 148 |
+
--sds-color-accent-primary: #ee3243;
|
| 149 |
+
--sds-space-gap-small: 0.5rem;
|
| 150 |
+
--sds-space-gap-medium: 1rem;
|
| 151 |
+
--sds-space-gap-large: 1.5rem;
|
| 152 |
+
--sds-space-padding-small: 0.75rem;
|
| 153 |
+
--sds-space-padding-medium: 1rem;
|
| 154 |
+
--sds-space-padding-large: 1.5rem;
|
| 155 |
+
--sds-space-border-radius-small: 4px;
|
| 156 |
+
--sds-space-border-radius-medium: 8px;
|
| 157 |
+
--sds-space-border-radius-large: 12px;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
.gradio-container {
|
| 161 |
+
font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
|
| 162 |
}
|
| 163 |
+
|
| 164 |
+
h1, .gr-title {
|
| 165 |
+
color: var(--sds-color-text-secondary) !important;
|
| 166 |
+
font-weight: 600 !important;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
.gr-box {
|
| 170 |
+
border-radius: var(--sds-space-border-radius-medium) !important;
|
| 171 |
}
|
| 172 |
+
|
| 173 |
+
.gr-button {
|
| 174 |
+
background-color: var(--sds-color-interaction-primary) !important;
|
| 175 |
+
border-color: var(--sds-color-interaction-primary) !important;
|
| 176 |
+
border-radius: var(--sds-space-border-radius-small) !important;
|
| 177 |
+
font-weight: 500 !important;
|
| 178 |
+
transition: all 0.2s ease !important;
|
| 179 |
}
|
| 180 |
+
|
| 181 |
+
.gr-button:hover {
|
| 182 |
+
background-color: var(--sds-color-interaction-primary-hover) !important;
|
| 183 |
+
border-color: var(--sds-color-interaction-primary-hover) !important;
|
| 184 |
+
transform: translateY(-1px) !important;
|
| 185 |
+
box-shadow: 0 2px 8px rgba(125, 93, 166, 0.3) !important;
|
| 186 |
}
|
| 187 |
+
|
| 188 |
+
.gr-button-primary {
|
| 189 |
+
background: linear-gradient(135deg, var(--sds-color-interaction-primary) 0%, #6b4d94 100%) !important;
|
| 190 |
}
|
| 191 |
+
|
| 192 |
+
.gr-input, .gr-textbox {
|
| 193 |
+
border-color: #e0e0e0 !important;
|
| 194 |
+
border-radius: var(--sds-space-border-radius-small) !important;
|
| 195 |
}
|
| 196 |
+
|
| 197 |
+
.gr-input:focus, .gr-textbox:focus {
|
| 198 |
+
border-color: var(--sds-color-interaction-primary) !important;
|
| 199 |
+
box-shadow: 0 0 0 2px rgba(125, 93, 166, 0.1) !important;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
.gr-panel {
|
| 203 |
+
background-color: var(--sds-color-layout-background-subtle) !important;
|
| 204 |
+
border-radius: var(--sds-space-border-radius-medium) !important;
|
| 205 |
+
padding: var(--sds-space-padding-large) !important;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
.gr-form {
|
| 209 |
+
gap: var(--sds-space-gap-medium) !important;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
footer {
|
| 213 |
+
background-color: var(--sds-color-layout-background-subtle) !important;
|
| 214 |
+
border-top: 1px solid #e0e0e0 !important;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
.sikt-logo {
|
| 218 |
+
max-width: 120px;
|
| 219 |
+
height: auto;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
.sikt-header {
|
| 223 |
+
background: linear-gradient(135deg, #f3f1fe 0%, #ffffff 100%);
|
| 224 |
+
padding: var(--sds-space-padding-medium);
|
| 225 |
+
border-radius: var(--sds-space-border-radius-medium);
|
| 226 |
+
margin-bottom: var(--sds-space-gap-large);
|
| 227 |
+
border-left: 4px solid var(--sds-color-interaction-primary);
|
| 228 |
}
|
| 229 |
"""
|
| 230 |
|
|
|
|
| 237 |
label="Survey Question"
|
| 238 |
),
|
| 239 |
outputs=gr.Markdown(label="Classification Result"),
|
| 240 |
+
title="ESS Variable Classification",
|
| 241 |
description="""
|
| 242 |
+
<div class="sikt-header">
|
| 243 |
+
<div style="display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;">
|
| 244 |
+
<img src="file/Sikt-Primærlogo-Mørk_0.png" alt="Sikt Logo" class="sikt-logo">
|
| 245 |
+
<div style="flex: 1; min-width: 300px;">
|
| 246 |
+
<h3 style="margin: 0 0 0.5rem 0; color: var(--sds-color-text-secondary); font-size: 1.25rem; font-weight: 600;">
|
| 247 |
+
ESS Variable Classifier
|
| 248 |
+
</h3>
|
| 249 |
+
<p style="margin: 0; color: var(--sds-color-text-primary); font-size: 0.95rem; line-height: 1.5;">
|
| 250 |
+
Developed by <strong>Sikt</strong> – Norwegian Agency for Shared Services in Education and Research
|
| 251 |
+
</p>
|
| 252 |
+
</div>
|
| 253 |
</div>
|
| 254 |
</div>
|
| 255 |
|
| 256 |
+
<div style="margin: 1.5rem 0;">
|
| 257 |
+
<p style="font-size: 1.05rem; color: var(--sds-color-text-primary); line-height: 1.6;">
|
| 258 |
+
Automatically classify European Social Survey (ESS) questions into <strong>19 subject categories</strong>.
|
| 259 |
+
This AI model is fine-tuned from XLM-RoBERTa-Base and achieves <strong>83.8% accuracy</strong>.
|
| 260 |
+
</p>
|
| 261 |
+
</div>
|
| 262 |
""",
|
| 263 |
examples=examples,
|
| 264 |
article="""
|
| 265 |
+
<div style="margin-top: 2rem; padding-top: 2rem; border-top: 2px solid var(--sds-color-layout-background-subtle);">
|
| 266 |
+
|
| 267 |
+
<div style="background: linear-gradient(135deg, #f3f1fe 0%, #ffffff 100%); padding: 1.5rem; border-radius: var(--sds-space-border-radius-medium); margin-bottom: 2rem; border-left: 4px solid var(--sds-color-interaction-primary);">
|
| 268 |
+
<h3 style="color: var(--sds-color-text-secondary); margin-top: 0; font-weight: 600;">📊 About This Tool</h3>
|
| 269 |
+
<p style="color: var(--sds-color-text-primary); line-height: 1.6;">
|
| 270 |
+
This classifier helps researchers and data managers organize survey variables by automatically
|
| 271 |
+
categorizing them into subject areas. The model was trained on European Social Survey metadata
|
| 272 |
+
and can classify questions into <strong>19 categories</strong>:
|
| 273 |
+
</p>
|
| 274 |
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.5rem; margin-top: 1rem;">
|
| 275 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.9rem;">📚 Education</span>
|
| 276 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.9rem;">🏛️ Politics</span>
|
| 277 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.9rem;">🏥 Health</span>
|
| 278 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.9rem;">💼 Labour & Employment</span>
|
| 279 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.9rem;">🌍 Society & Culture</span>
|
| 280 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.9rem;">💰 Economics</span>
|
| 281 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.9rem;">🧠 Psychology</span>
|
| 282 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.9rem;">👥 Demographics</span>
|
| 283 |
+
</div>
|
| 284 |
+
<p style="color: #666; margin-top: 1rem; font-size: 0.9rem;"><em>...and 11 more specialized categories</em></p>
|
| 285 |
+
</div>
|
|
|
|
|
|
|
| 286 |
|
| 287 |
+
<div style="background: white; padding: 1.5rem; border-radius: var(--sds-space-border-radius-medium); margin-bottom: 2rem; border: 1px solid #e0e0e0;">
|
| 288 |
+
<h3 style="color: var(--sds-color-text-secondary); margin-top: 0; font-weight: 600;">🔬 Technical Details</h3>
|
| 289 |
+
<ul style="color: var(--sds-color-text-primary); line-height: 1.8; padding-left: 1.5rem;">
|
| 290 |
+
<li><strong>Base Model:</strong> <a href="https://huggingface.co/FacebookAI/xlm-roberta-base" style="color: var(--sds-color-interaction-primary);">XLM-RoBERTa-Base</a> (125M parameters)</li>
|
| 291 |
+
<li><strong>Fine-tuned Model:</strong> <a href="https://huggingface.co/benjaminBeuster/xlm-roberta-base-ess-classification" style="color: var(--sds-color-interaction-primary);">benjaminBeuster/xlm-roberta-base-ess-classification</a></li>
|
| 292 |
+
<li><strong>Performance:</strong> 83.8% accuracy | F1: 0.796 (weighted) | 105 test samples</li>
|
| 293 |
+
<li><strong>Training Data:</strong> <a href="https://huggingface.co/datasets/benjaminBeuster/ess_classification" style="color: var(--sds-color-interaction-primary);">ESS Classification Dataset</a></li>
|
| 294 |
+
</ul>
|
| 295 |
+
</div>
|
| 296 |
|
| 297 |
+
<div style="background: linear-gradient(135deg, var(--sds-color-layout-background-subtle) 0%, white 100%); padding: 1.5rem; border-radius: var(--sds-space-border-radius-medium); text-align: center;">
|
| 298 |
+
<h3 style="color: var(--sds-color-text-secondary); margin-top: 0; font-weight: 600;">About Sikt</h3>
|
| 299 |
+
<p style="color: var(--sds-color-text-primary); line-height: 1.6; max-width: 600px; margin: 0 auto 1rem auto;">
|
| 300 |
+
<a href="https://sikt.no" style="color: var(--sds-color-interaction-primary); text-decoration: none; font-weight: 600;">Sikt</a>
|
| 301 |
+
– Norwegian Agency for Shared Services in Education and Research provides digital infrastructure
|
| 302 |
+
and services for research and education in Norway.
|
| 303 |
+
</p>
|
| 304 |
+
<p style="margin-top: 1.5rem;">
|
| 305 |
+
<a href="https://sikt.no" style="display: inline-block; padding: 0.75rem 1.5rem; background-color: var(--sds-color-interaction-primary); color: white; text-decoration: none; border-radius: var(--sds-space-border-radius-small); font-weight: 600; transition: all 0.2s;">
|
| 306 |
+
Visit sikt.no →
|
| 307 |
+
</a>
|
| 308 |
</p>
|
| 309 |
</div>
|
| 310 |
+
|
| 311 |
+
</div>
|
| 312 |
""",
|
| 313 |
theme=gr.themes.Soft(
|
| 314 |
primary_hue="red",
|