m-newhauser commited on
Commit
5f2a3d9
·
verified ·
1 Parent(s): 2f83474

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. static/index.html +6 -2
static/index.html CHANGED
@@ -247,6 +247,7 @@ let READY = false, timer = null, version = 0, TASKS = {}, LAST = null, MODE = "g
247
  min: {type: "min", task, k} -> at least k labels selected on task */
248
  let RULES = [
249
  { "if": ["harm_category", "*"], "then": ["safety", "unsafe"] },
 
250
  ];
251
 
252
  const RULE_TYPE = {
@@ -254,6 +255,7 @@ const RULE_TYPE = {
254
  min: "ALWAYS at least one label",
255
  };
256
  const DEFAULT_MIN_RULE = () => ({ type: "min", task: "harm_category", k: 1 });
 
257
 
258
  function renderRules() {
259
  const box = $("rule-list");
@@ -321,7 +323,7 @@ function renderRules() {
321
  }
322
 
323
  $("add-rule").addEventListener("click", () => {
324
- RULES.push(DEFAULT_MIN_RULE());
325
  renderRules();
326
  inferSoon(120);
327
  });
@@ -411,7 +413,9 @@ function renderResult(data) {
411
  } else if (nRules === 0) {
412
  note = `<p class="out-note">No rules declared, so the joint decode matches the separate one. Add a rule on the left to constrain it.</p>`;
413
  } else if (violated) {
414
- note = `<p class="out-note">GLiNER 2.5 decodes both tasks jointly under your ${nRules === 1 ? "rule" : "rules"}: the flagged harm labels carry less combined utility than the safety score, so the decoder drops them and keeps <b>safe</b>: a coherent assignment.</p>`;
 
 
415
  } else {
416
  note = `<p class="out-note">GLiNER 2.5 decodes both tasks jointly under your ${nRules === 1 ? "rule" : "rules"}: <b>${esc(joiSafety[0] || "")}</b> with ${joiStrat.length ? `<b>${joiStrat.map(esc).join(", ")}</b>` : "no harm labels"}: a coherent assignment.</p>`;
417
  }
 
247
  min: {type: "min", task, k} -> at least k labels selected on task */
248
  let RULES = [
249
  { "if": ["harm_category", "*"], "then": ["safety", "unsafe"] },
250
+ { type: "min", task: "harm_category", k: 1 },
251
  ];
252
 
253
  const RULE_TYPE = {
 
255
  min: "ALWAYS at least one label",
256
  };
257
  const DEFAULT_MIN_RULE = () => ({ type: "min", task: "harm_category", k: 1 });
258
+ const DEFAULT_IF_RULE = () => ({ "if": ["safety", "unsafe"], "then": ["harm_category", "*"] });
259
 
260
  function renderRules() {
261
  const box = $("rule-list");
 
323
  }
324
 
325
  $("add-rule").addEventListener("click", () => {
326
+ RULES.push(RULES.some((r) => r.type === "min") ? DEFAULT_IF_RULE() : DEFAULT_MIN_RULE());
327
  renderRules();
328
  inferSoon(120);
329
  });
 
413
  } else if (nRules === 0) {
414
  note = `<p class="out-note">No rules declared, so the joint decode matches the separate one. Add a rule on the left to constrain it.</p>`;
415
  } else if (violated) {
416
+ note = (joiSafety[0] === "unsafe" && joiStrat.length)
417
+ ? `<p class="out-note">GLiNER 2.5 decodes both tasks jointly under your ${nRules === 1 ? "rule" : "rules"}: the harm flag cannot coexist with a safe verdict, so the decoder escalates to <b>unsafe</b> — a coherent assignment.</p>`
418
+ : `<p class="out-note">GLiNER 2.5 decodes both tasks jointly under your ${nRules === 1 ? "rule" : "rules"}: the flagged harm labels carry less combined utility than the safety score, so the decoder drops them and keeps <b>safe</b> — a coherent assignment.</p>`;
419
  } else {
420
  note = `<p class="out-note">GLiNER 2.5 decodes both tasks jointly under your ${nRules === 1 ? "rule" : "rules"}: <b>${esc(joiSafety[0] || "")}</b> with ${joiStrat.length ? `<b>${joiStrat.map(esc).join(", ")}</b>` : "no harm labels"}: a coherent assignment.</p>`;
421
  }