rafmacalaba commited on
Commit
e58f371
·
verified ·
1 Parent(s): 5005357

show luna reasoning on disagreement

Browse files
Files changed (1) hide show
  1. review.html +13 -12
review.html CHANGED
@@ -147,6 +147,15 @@ const QD = document.documentElement;
147
  QD.dataset.theme = localStorage.getItem('review_theme') || 'light';
148
  function theme() { QD.dataset.theme = QD.dataset.theme === 'light' ? 'dark' : 'light'; localStorage.setItem('review_theme', QD.dataset.theme); }
149
  const who = () => ($('who').value || '').trim();
 
 
 
 
 
 
 
 
 
150
  function loadWho() {
151
  $('who').value = localStorage.getItem('review_who') || '';
152
  $('who').addEventListener('input', () => {
@@ -189,15 +198,6 @@ function needName() {
189
  return true;
190
  }
191
 
192
- // normalize legacy single-span items -> spans[]
193
- function norm(o) {
194
- if (o.spans) return o;
195
- return {...o, spans: [{key: o.key, start: o.start, end: o.end, surface: o.surface,
196
- luna_label: o.ref ? (o.ref.luna_label === 1 ? 1 : 0) : undefined,
197
- human_verdict: o.ref && o.ref.human_verdict, human_note: o.ref && o.ref.human_note,
198
- probe_tag: undefined, probe_score: o.ref && o.ref.head_score,
199
- pred: o.ref && o.ref.pred}]};
200
- }
201
  async function loadDs() {
202
  const q = await (await fetch(DS[$('ds').value])).json();
203
  ALL = q.map(norm);
@@ -281,12 +281,13 @@ function renderRef(sp) {
281
  ? `<span style="color:var(--mut)">${subj}: you agree with Luna</span>`
282
  : `<b class="d">DISAGREE</b> <span style="color:var(--mut)">— ${subj}: Luna ${lunaKeep ? 'kept this, you\u2019re dropping' : 'dropped this, you\u2019re keeping'}</span>`;
283
  let detail;
 
284
  if (sp.luna_label !== undefined && sp.human_verdict) {
285
  const g = lunaKeep ? '<b class="k">KEEP</b>' : '<b class="d">DROP</b>';
286
- detail = `gold ${g} · human ${esc(sp.human_verdict)}${sp.human_note ? ' (' + esc(sp.human_note) + ')' : ''} · model ${sp.pred} @ ${sp.probe_score}`;
287
  } else {
288
  const g = lunaKeep ? '<b class="k">KEEP</b>' : '<b class="d">DROP</b>';
289
- detail = `luna ${g} · probe ${esc(sp.probe_tag)} @ ${sp.probe_score}`;
290
  }
291
  $('ref').innerHTML = `${flag} · ${detail}`;
292
  }
@@ -390,7 +391,7 @@ async function rule(v) {
390
  // warning toast on disagreement (stays until dismissed)
391
  const sp0 = span(), dk = (v === 'DATA_MENTION') !== (sp0.luna_label === 1);
392
  light();
393
- if (dk) warnToast(`DISAGREE — “${sp0.surface}”: Luna ${sp0.luna_label === 1 ? 'kept this, you’re dropping' : 'dropped this, you’re keeping'}`);
394
  }
395
  async function sinkCommit(entry) {
396
  // shared sink (Cloudflare Worker) if configured, else the annotator's
 
147
  QD.dataset.theme = localStorage.getItem('review_theme') || 'light';
148
  function theme() { QD.dataset.theme = QD.dataset.theme === 'light' ? 'dark' : 'light'; localStorage.setItem('review_theme', QD.dataset.theme); }
149
  const who = () => ($('who').value || '').trim();
150
+ // normalize legacy single-span items -> spans[]
151
+ function norm(o) {
152
+ if (o.spans) return o;
153
+ return {...o, spans: [{key: o.key, start: o.start, end: o.end, surface: o.surface,
154
+ luna_label: o.ref ? (o.ref.luna_label === 1 ? 1 : 0) : undefined,
155
+ human_verdict: o.ref && o.ref.human_verdict, human_note: o.ref && o.ref.human_note,
156
+ probe_tag: undefined, probe_score: o.ref && o.ref.head_score, luna_reason: o.ref && o.ref.luna_reason,
157
+ pred: o.ref && o.ref.pred}]};
158
+ }
159
  function loadWho() {
160
  $('who').value = localStorage.getItem('review_who') || '';
161
  $('who').addEventListener('input', () => {
 
198
  return true;
199
  }
200
 
 
 
 
 
 
 
 
 
 
201
  async function loadDs() {
202
  const q = await (await fetch(DS[$('ds').value])).json();
203
  ALL = q.map(norm);
 
281
  ? `<span style="color:var(--mut)">${subj}: you agree with Luna</span>`
282
  : `<b class="d">DISAGREE</b> <span style="color:var(--mut)">— ${subj}: Luna ${lunaKeep ? 'kept this, you\u2019re dropping' : 'dropped this, you\u2019re keeping'}</span>`;
283
  let detail;
284
+ const why = sp.luna_reason ? ` · Luna's reasoning: “${esc(sp.luna_reason)}”` : '';
285
  if (sp.luna_label !== undefined && sp.human_verdict) {
286
  const g = lunaKeep ? '<b class="k">KEEP</b>' : '<b class="d">DROP</b>';
287
+ detail = `gold ${g} · human ${esc(sp.human_verdict)}${sp.human_note ? ' (' + esc(sp.human_note) + ')' : ''} · model ${sp.pred} @ ${sp.probe_score}${why}`;
288
  } else {
289
  const g = lunaKeep ? '<b class="k">KEEP</b>' : '<b class="d">DROP</b>';
290
+ detail = `luna ${g} · probe ${esc(sp.probe_tag)} @ ${sp.probe_score}${why}`;
291
  }
292
  $('ref').innerHTML = `${flag} · ${detail}`;
293
  }
 
391
  // warning toast on disagreement (stays until dismissed)
392
  const sp0 = span(), dk = (v === 'DATA_MENTION') !== (sp0.luna_label === 1);
393
  light();
394
+ if (dk) warnToast(`DISAGREE — “${sp0.surface}”: Luna ${sp0.luna_label === 1 ? 'kept this, you’re dropping' : 'dropped this, you’re keeping'}` + (sp0.luna_reason ? ` — Luna's reasoning: “${sp0.luna_reason}”` : ''));
395
  }
396
  async function sinkCommit(entry) {
397
  // shared sink (Cloudflare Worker) if configured, else the annotator's