gabrielchua commited on
Commit
6bd689e
·
verified ·
1 Parent(s): 1bc2a4e

Update app/frontend/index.html

Browse files
Files changed (1) hide show
  1. app/frontend/index.html +164 -20
app/frontend/index.html CHANGED
@@ -3,7 +3,22 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Lionguard</title>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  <link rel="stylesheet" href="/static/style.css">
8
  </head>
9
  <body>
@@ -20,34 +35,38 @@
20
  </div>
21
  <div class="header-controls">
22
  <nav class="tabs" aria-label="Primary navigation">
 
 
 
 
23
  <div class="nav-dropdown">
24
  <button
25
  class="tab dropdown-toggle"
26
  aria-haspopup="true"
27
  aria-expanded="false"
28
  >
29
- <span class="tab-icon">🛠️</span>
30
  Demos
31
- <span class="dropdown-caret">▾</span>
32
  </button>
33
  <div class="dropdown-menu" role="menu">
34
  <button class="tab dropdown-item active" data-tab="detector" role="menuitem">
35
- <span class="tab-icon">🔍</span>
36
  Detector
37
  </button>
38
  <button class="tab dropdown-item" data-tab="chat" role="menuitem">
39
- <span class="tab-icon">💬</span>
40
  Chatbot Guardrail
41
  </button>
42
  </div>
43
  </div>
44
  <button class="tab nav-link" data-tab="about">
45
- <span class="tab-icon">ℹ️</span>
46
  About
47
  </button>
48
  </nav>
49
  <button id="theme-toggle" class="theme-icon-button" aria-label="Toggle theme">
50
- <span class="theme-icon" aria-hidden="true">🌞</span>
51
  </button>
52
  </div>
53
  </div>
@@ -60,7 +79,7 @@
60
  <div id="detector-content" class="tab-content active">
61
  <!-- Disclaimer -->
62
  <div class="warning-card">
63
- ⚠️ Inputs are anonymised and logged to improve Lionguard's moderation models.
64
  </div>
65
 
66
  <!-- Model Selector -->
@@ -88,7 +107,7 @@
88
  rows="10"
89
  ></textarea>
90
  <button id="analyze-btn" class="btn btn-primary">
91
- <span class="btn-icon">🔍</span>
92
  Analyze
93
  </button>
94
  </div>
@@ -99,7 +118,7 @@
99
 
100
  <!-- Binary Score -->
101
  <div id="binary-result" class="binary-placeholder">
102
- <div class="placeholder-icon">📝</div>
103
  <p>Enter text to analyze</p>
104
  </div>
105
 
@@ -113,11 +132,11 @@
113
  <p class="feedback-prompt">Does this look correct?</p>
114
  <div class="feedback-buttons">
115
  <button id="thumbs-up" class="btn btn-success">
116
- <span>👍</span>
117
  Yes
118
  </button>
119
  <button id="thumbs-down" class="btn btn-secondary">
120
- <span>👎</span>
121
  No
122
  </button>
123
  </div>
@@ -131,7 +150,7 @@
131
  <div id="chat-content" class="tab-content full-width-section">
132
  <!-- Disclaimer -->
133
  <div class="warning-card">
134
- ⚠️ Inputs are anonymised and logged to improve Lionguard's moderation models.
135
  </div>
136
 
137
  <!-- Model Selector for Guardrail -->
@@ -153,7 +172,7 @@
153
  <!-- No Moderation -->
154
  <div class="chat-panel">
155
  <div class="chat-header">
156
- <span class="chat-icon">🔵</span>
157
  <h4>No Moderation</h4>
158
  </div>
159
  <div id="chat-no-mod" class="chat-messages"></div>
@@ -162,7 +181,7 @@
162
  <!-- OpenAI Moderation -->
163
  <div class="chat-panel">
164
  <div class="chat-header">
165
- <span class="chat-icon">🟠</span>
166
  <h4>OpenAI Moderation</h4>
167
  </div>
168
  <div id="chat-openai" class="chat-messages"></div>
@@ -171,7 +190,7 @@
171
  <!-- Lionguard -->
172
  <div class="chat-panel">
173
  <div class="chat-header">
174
- <span class="chat-icon">🛡️</span>
175
  <h4>Lionguard</h4>
176
  </div>
177
  <div id="chat-lionguard" class="chat-messages"></div>
@@ -204,7 +223,7 @@
204
  <section class="about-resources-grid">
205
  <!-- Models -->
206
  <div class="resource-card">
207
- <h3>🤗 Open-Sourced Models</h3>
208
  <div class="resource-list">
209
  <a href="https://huggingface.co/govtech/lionguard-2.1" target="_blank">Lionguard 2.1</a>
210
  <a href="https://huggingface.co/govtech/lionguard-2" target="_blank">Lionguard 2</a>
@@ -215,7 +234,7 @@
215
 
216
  <!-- Datasets -->
217
  <div class="resource-card">
218
- <h3>📊 Open-Sourced Datasets</h3>
219
  <div class="resource-list">
220
  <a href="https://huggingface.co/datasets/govtech/lionguard-2-synthetic-instruct" target="_blank">Subset of Training Data</a>
221
  <a href="https://huggingface.co/datasets/govtech/RabakBench" target="_blank">RabakBench</a>
@@ -224,7 +243,7 @@
224
 
225
  <!-- Blog Posts -->
226
  <div class="resource-card">
227
- <h3>📝 Blog Posts</h3>
228
  <div class="resource-list">
229
  <a href="https://medium.com/dsaid-govtech/lionguard-2-8066d4e20d16" target="_blank">Lionguard 2</a>
230
  <a href="https://medium.com/dsaid-govtech/building-lionguard-a-contextualised-moderation-classifier-to-tackle-local-unsafe-content-8f68c8f13179" target="_blank">Lionguard</a>
@@ -233,7 +252,7 @@
233
 
234
  <!-- Papers -->
235
  <div class="resource-card">
236
- <h3>📄 Research Papers</h3>
237
  <div class="resource-list">
238
  <a href="https://arxiv.org/abs/2507.05980" target="_blank">Lionguard 2 (arXiv:2507.05980)</a>
239
  <a href="https://arxiv.org/abs/2507.15339" target="_blank">RabakBench (arXiv:2507.15339)</a>
@@ -242,6 +261,127 @@
242
  </div>
243
  </section>
244
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  </main>
246
 
247
  <!-- Footer -->
@@ -252,5 +392,9 @@
252
  </footer>
253
 
254
  <script src="/static/script.js"></script>
 
 
 
 
255
  </body>
256
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <meta name="description" content="Lionguard: A content moderation tool designed for Singapore's multilingual environment.">
7
+ <meta name="theme-color" content="#E14746">
8
+ <title>Lionguard - Content Moderation</title>
9
+ <link rel="icon" type="image/png" href="/static/logo.png">
10
+
11
+ <!-- Fonts -->
12
+ <link rel="preconnect" href="https://fonts.googleapis.com">
13
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
14
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@500;600;700&display=swap" rel="stylesheet">
15
+
16
+ <!-- Icons -->
17
+ <link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
18
+
19
+ <!-- Syntax Highlighting -->
20
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" rel="stylesheet" />
21
+
22
  <link rel="stylesheet" href="/static/style.css">
23
  </head>
24
  <body>
 
35
  </div>
36
  <div class="header-controls">
37
  <nav class="tabs" aria-label="Primary navigation">
38
+ <button class="tab nav-link" data-tab="get-started">
39
+ <i class='bx bx-rocket tab-icon'></i>
40
+ Get Started
41
+ </button>
42
  <div class="nav-dropdown">
43
  <button
44
  class="tab dropdown-toggle"
45
  aria-haspopup="true"
46
  aria-expanded="false"
47
  >
48
+ <i class='bx bx-grid-alt tab-icon'></i>
49
  Demos
50
+ <i class='bx bx-chevron-down dropdown-caret'></i>
51
  </button>
52
  <div class="dropdown-menu" role="menu">
53
  <button class="tab dropdown-item active" data-tab="detector" role="menuitem">
54
+ <i class='bx bx-search tab-icon'></i>
55
  Detector
56
  </button>
57
  <button class="tab dropdown-item" data-tab="chat" role="menuitem">
58
+ <i class='bx bx-message-rounded-dots tab-icon'></i>
59
  Chatbot Guardrail
60
  </button>
61
  </div>
62
  </div>
63
  <button class="tab nav-link" data-tab="about">
64
+ <i class='bx bx-info-circle tab-icon'></i>
65
  About
66
  </button>
67
  </nav>
68
  <button id="theme-toggle" class="theme-icon-button" aria-label="Toggle theme">
69
+ <i class='bx bx-sun theme-icon'></i>
70
  </button>
71
  </div>
72
  </div>
 
79
  <div id="detector-content" class="tab-content active">
80
  <!-- Disclaimer -->
81
  <div class="warning-card">
82
+ <i class='bx bx-error-circle'></i> Inputs are anonymised and logged to improve Lionguard's moderation models.
83
  </div>
84
 
85
  <!-- Model Selector -->
 
107
  rows="10"
108
  ></textarea>
109
  <button id="analyze-btn" class="btn btn-primary">
110
+ <i class='bx bx-search btn-icon'></i>
111
  Analyze
112
  </button>
113
  </div>
 
118
 
119
  <!-- Binary Score -->
120
  <div id="binary-result" class="binary-placeholder">
121
+ <i class='bx bx-edit placeholder-icon'></i>
122
  <p>Enter text to analyze</p>
123
  </div>
124
 
 
132
  <p class="feedback-prompt">Does this look correct?</p>
133
  <div class="feedback-buttons">
134
  <button id="thumbs-up" class="btn btn-success">
135
+ <i class='bx bx-like'></i>
136
  Yes
137
  </button>
138
  <button id="thumbs-down" class="btn btn-secondary">
139
+ <i class='bx bx-dislike'></i>
140
  No
141
  </button>
142
  </div>
 
150
  <div id="chat-content" class="tab-content full-width-section">
151
  <!-- Disclaimer -->
152
  <div class="warning-card">
153
+ <i class='bx bx-error-circle'></i> Inputs are anonymised and logged to improve Lionguard's moderation models.
154
  </div>
155
 
156
  <!-- Model Selector for Guardrail -->
 
172
  <!-- No Moderation -->
173
  <div class="chat-panel">
174
  <div class="chat-header">
175
+ <i class='bx bxs-circle chat-icon' style="color: #3B82F6;"></i>
176
  <h4>No Moderation</h4>
177
  </div>
178
  <div id="chat-no-mod" class="chat-messages"></div>
 
181
  <!-- OpenAI Moderation -->
182
  <div class="chat-panel">
183
  <div class="chat-header">
184
+ <i class='bx bxs-circle chat-icon' style="color: #F59E0B;"></i>
185
  <h4>OpenAI Moderation</h4>
186
  </div>
187
  <div id="chat-openai" class="chat-messages"></div>
 
190
  <!-- Lionguard -->
191
  <div class="chat-panel">
192
  <div class="chat-header">
193
+ <i class='bx bx-shield-quarter chat-icon' style="color: #E14746;"></i>
194
  <h4>Lionguard</h4>
195
  </div>
196
  <div id="chat-lionguard" class="chat-messages"></div>
 
223
  <section class="about-resources-grid">
224
  <!-- Models -->
225
  <div class="resource-card">
226
+ <h3><i class='bx bx-cube-alt'></i> Open-Sourced Models</h3>
227
  <div class="resource-list">
228
  <a href="https://huggingface.co/govtech/lionguard-2.1" target="_blank">Lionguard 2.1</a>
229
  <a href="https://huggingface.co/govtech/lionguard-2" target="_blank">Lionguard 2</a>
 
234
 
235
  <!-- Datasets -->
236
  <div class="resource-card">
237
+ <h3><i class='bx bx-data'></i> Open-Sourced Datasets</h3>
238
  <div class="resource-list">
239
  <a href="https://huggingface.co/datasets/govtech/lionguard-2-synthetic-instruct" target="_blank">Subset of Training Data</a>
240
  <a href="https://huggingface.co/datasets/govtech/RabakBench" target="_blank">RabakBench</a>
 
243
 
244
  <!-- Blog Posts -->
245
  <div class="resource-card">
246
+ <h3><i class='bx bx-news'></i> Blog Posts</h3>
247
  <div class="resource-list">
248
  <a href="https://medium.com/dsaid-govtech/lionguard-2-8066d4e20d16" target="_blank">Lionguard 2</a>
249
  <a href="https://medium.com/dsaid-govtech/building-lionguard-a-contextualised-moderation-classifier-to-tackle-local-unsafe-content-8f68c8f13179" target="_blank">Lionguard</a>
 
252
 
253
  <!-- Papers -->
254
  <div class="resource-card">
255
+ <h3><i class='bx bx-file'></i> Research Papers</h3>
256
  <div class="resource-list">
257
  <a href="https://arxiv.org/abs/2507.05980" target="_blank">Lionguard 2 (arXiv:2507.05980)</a>
258
  <a href="https://arxiv.org/abs/2507.15339" target="_blank">RabakBench (arXiv:2507.15339)</a>
 
261
  </div>
262
  </section>
263
  </div>
264
+
265
+ <!-- Get Started Tab Content -->
266
+ <div id="get-started-content" class="tab-content">
267
+ <div class="get-started-container">
268
+ <!-- Option 1 -->
269
+ <div class="option-card full-width-card">
270
+ <div class="option-header">
271
+ <i class='bx bx-server option-icon'></i>
272
+ <div>
273
+ <h2>Option 1: Self-Host the Classifier</h2>
274
+ <p>Integrate Lionguard directly into your applications. Toggle between models to see the implementation details.</p>
275
+ </div>
276
+ </div>
277
+
278
+ <div class="code-section">
279
+ <div class="code-tabs-header">
280
+ <div class="code-tabs">
281
+ <button class="code-tab active" data-code="lg2.1">Lionguard 2.1</button>
282
+ <button class="code-tab" data-code="lg2">Lionguard 2</button>
283
+ <button class="code-tab" data-code="lg2-lite">Lionguard 2 Lite</button>
284
+ </div>
285
+ <button id="copy-code-btn" class="copy-btn" title="Copy to clipboard">
286
+ <i class='bx bx-copy'></i> Copy
287
+ </button>
288
+ </div>
289
+
290
+ <div class="code-display">
291
+ <!-- Lionguard 2.1 Snippet -->
292
+ <div id="code-lg2.1" class="code-block active">
293
+ <pre><code class="language-python">import os
294
+ import numpy as np
295
+ from transformers import AutoModel
296
+ from google import genai
297
+
298
+ # Load model directly from HF
299
+ model = AutoModel.from_pretrained("govtech/lionguard-2.1", trust_remote_code=True)
300
+
301
+ # Text to classify
302
+ texts = ["hello", "world"]
303
+
304
+ # Get embeddings (users to input their own Gemini API key)
305
+ client = genai.Client(api_key=os.getenv("GEMINI_API_KEY"))
306
+ response = client.models.embed_content(
307
+ model="gemini-embedding-001",
308
+ contents=texts
309
+ )
310
+ embeddings = np.array([emb.values for emb in response.embeddings])
311
+
312
+ # Run inference
313
+ results = model.predict(embeddings)</code></pre>
314
+ </div>
315
+
316
+ <!-- Lionguard 2 Snippet -->
317
+ <div id="code-lg2" class="code-block">
318
+ <pre><code class="language-python">import os
319
+ import numpy as np
320
+ from transformers import AutoModel
321
+ from openai import OpenAI
322
+
323
+ # Load model directly from HF
324
+ model = AutoModel.from_pretrained(
325
+ "govtech/lionguard-2",
326
+ trust_remote_code=True
327
+ )
328
+
329
+ # Get OpenAI embeddings (users to input their own OpenAI API key)
330
+ client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
331
+ response = client.embeddings.create(
332
+ input="Hello, world!", # users to input their own text
333
+ model="text-embedding-3-large",
334
+ dimensions=3072 # dimensions of the embedding
335
+ )
336
+ embeddings = np.array([data.embedding for data in response.data])
337
+
338
+ # Run LionGuard 2
339
+ results = model.predict(embeddings)</code></pre>
340
+ </div>
341
+
342
+ <!-- Lionguard 2 Lite Snippet -->
343
+ <div id="code-lg2-lite" class="code-block">
344
+ <pre><code class="language-python">import numpy as np
345
+ from sentence_transformers import SentenceTransformer
346
+ from transformers import AutoModel
347
+
348
+ # Load model directly from Hub
349
+ model = AutoModel.from_pretrained("govtech/lionguard-2-lite", trust_remote_code=True)
350
+
351
+ # Download model from the 🤗 Hub
352
+ embedding_model = SentenceTransformer("google/embeddinggemma-300m")
353
+
354
+ # Text to classify
355
+ texts = ["hello", "world"]
356
+
357
+ # Add prompt instructions to generate embeddings that are optimized to classify texts according to preset labels
358
+ formatted_texts = [f"task: classification | query: {c}" for c in texts]
359
+ embeddings = embedding_model.encode(formatted_texts) # NOTE: use encode() instead of encode_documents()
360
+
361
+ # Run inference
362
+ results = model.predict(embeddings)</code></pre>
363
+ </div>
364
+ </div>
365
+ </div>
366
+ </div>
367
+
368
+ <!-- Option 2 -->
369
+ <div class="option-card full-width-card">
370
+ <div class="option-header">
371
+ <i class='bx bx-shield-quarter option-icon'></i>
372
+ <div>
373
+ <h2>Option 2: via AI Guardians - Sentinel</h2>
374
+ <p>Managed service for Singapore public sector agencies.</p>
375
+ </div>
376
+ </div>
377
+ <div class="option-action">
378
+ <a href="https://www.aiguardian.gov.sg/" target="_blank" class="btn btn-primary">
379
+ Visit AI Guardians
380
+ </a>
381
+ </div>
382
+ </div>
383
+ </div>
384
+ </div>
385
  </main>
386
 
387
  <!-- Footer -->
 
392
  </footer>
393
 
394
  <script src="/static/script.js"></script>
395
+
396
+ <!-- Syntax Highlighting -->
397
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
398
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js"></script>
399
  </body>
400
  </html>