use case · basics · softmax vs sigmoid + hypothesis template lab · q8 WASM · 172.44 MB

Inside DeBERTa-v3 Zero-Shot

Understand the two knobs that control every zero-shot NLI classifier: Single-Label Softmax vs Multi-Label Independent Sigmoid, and how changing the wording of hypothesis_template shifts real on-device probabilities.

1 · DeBERTa-v3-Small NLI Worker (172.44 MB q8 WASM)

2 · Shared Premise & Candidate Labels

Prepare DeBERTa-v3-Small NLI above to run both live calibration experiments.

3 · Experiment A: Single-Label Softmax vs Multi-Label Independent Sigmoid

In multi_label: false, Transformers.js takes softmax across the entailment logits of all candidate labels so probabilities compete and sum to 100%. In multi_label: true, each label runs an independent 2-way softmax of [entailment, contradiction] so multiple true topics can score above 90% simultaneously.

Single-Label Sum —
Multi-Label Sum —
Multi ≥ 50% Count —
Mode Run Latency —
Label Single (Softmax) Multi (Sigmoid) Shift (Multi − Single) Raw Entail / Contra
Run Experiment A to compare single-label vs multi-label calibration.

4 · Experiment B: Hypothesis Template Sensitivity Lab

Zero-shot models do not see abstract class IDs — they score English sentences. Edit the three templates below (each must contain {}) and compare how phrasing alters probabilities and top-1 rankings on the exact same text.

Top-1 Stability —
Max Probability Shift (Δp) —
Most Sensitive Label —
3-Template Latency —
Label Template 1 Template 2 Template 3 Spread (Δp)
Run Experiment B to measure real hypothesis-template probability shifts.

5 · Show the Code

</> Show the code · worker.js exact multi_label & hypothesis_template calls
</> Show the code · nli-core.mjs pure template shift & dynamic id2label math