Views
No views yet
Input Text → DeBERTa-v3-large (FROZEN, one pass)
│ token embeddings (B, T, 1024)
┌──────────────┼──────────────┬─────────────┐
│ │ │ │
Economy Technology Finance Environment
PolyHead PolyHead PolyHead PolyHead
alpha_e alpha_t alpha_f alpha_v ← learned blend weights
│ │ │ │
└──────────────┼──────────────┴─────────────┘
│ Health: NLI-only (0.87 baseline)
val-tuned per-label thresholds
│
Final Predictions| Label | NLI Baseline | v2 Val-Tuned | Δ |
|---|---|---|---|
| Macro F1 | 0.6688 | 0.9054 | +0.2366 |
| Economy | 0.4354 | 0.8584 | +0.4230 |
| Technology | 0.7317 | 0.9447 | +0.2130 |
| Finance | 0.6826 | 0.8673 | +0.1847 |
| Environment | 0.6232 | 0.8786 | +0.2554 |
| Health | 0.8712 | 0.9780 | +0.1068 |
1from transformers import pipeline
2from huggingface_hub import hf_hub_download
3import torch
4
5# 1. Load DeBERTa backbone
6nli_pipe = pipeline(
7 'zero-shot-classification',
8 model='MoritzLaurer/deberta-v3-large-zeroshot-v2.0',
9 device=0
10)
11
12# 2. Download and load checkpoint
13ckpt_path = hf_hub_download(repo_id='tdnathmlenthusiast/hybrid-nli-polyencoder', filename='multihead_v2.pt')
14model, thresholds = load_model_from_checkpoint(ckpt_path, nli_pipe)
15model = model.to('cuda')
16
17# Move label embeddings to the correct device
18for l, emb in model._label_embs.items():
19 model._label_embs[l] = emb.to(model.device)
20
21# 3. Classify
22texts = ['The Fed raised rates to fight inflation.']
23nli_s = run_nli_inference([{'text': t} for t in texts])
24preds = model.predict(texts, nli_s, thresholds=thresholds)
25print(preds[0]['predicted_labels'])
26