oldman-dev commited on
Commit
68f0ff8
Β·
verified Β·
1 Parent(s): 44635b1

Add model card: TIS v2.2 supervised passage reranker

Browse files
Files changed (1) hide show
  1. README.md +125 -0
README.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: mistralai/Mistral-7B-v0.3
4
+ tags:
5
+ - passage-ranking
6
+ - information-retrieval
7
+ - ms-marco
8
+ - query-aware
9
+ - token-importance
10
+ language:
11
+ - en
12
+ datasets:
13
+ - microsoft/ms_marco
14
+ pipeline_tag: text-ranking
15
+ ---
16
+
17
+ # TIS v2.2 β€” Supervised Passage Reranker
18
+
19
+ **Token Importance Scoring v2.2**: Query-aware passage ranking trained on MS-MARCO relevance labels.
20
+
21
+ This is the first TIS checkpoint trained with *supervised* relevance labels (MS-MARCO `is_selected`). Earlier checkpoints (Stage3, v8b) used unsupervised ERT objectives. v2.2 resolves the score-direction ambiguity: **high-first (descending) is established by training construction**.
22
+
23
+ ## Performance (500 locked test queries, MS-MARCO v1.1)
24
+
25
+ | Method | MRR | Recall@1 | Recall@5 | NDCG@5 |
26
+ |---|---|---|---|---|
27
+ | BM25 (baseline) | 0.432 | 0.205 | 0.532 | β€” |
28
+ | TF-IDF (baseline) | 0.369 | 0.144 | 0.428 | β€” |
29
+ | **TIS v2.2 (this model)** | **0.471** | **0.253** | **0.795** | **0.529** |
30
+
31
+ **+9.1% MRR over BM25** (0.432 β†’ 0.471, 500 test queries, seed=42).
32
+
33
+ Release status: **Tier 2 Conditional** β€” beats BM25, below Tier 1 target (MRR β‰₯ 0.50). TIS v2.3 in progress.
34
+
35
+ ## Architecture
36
+
37
+ - **Base model**: Mistral-7B-Instruct-v0.3 (frozen, 4-bit NF4)
38
+ - **Importance head**: `QueryAwareImportanceHead` β€” 4-head cross-attention from passage tokens to mean-pooled query, followed by 3-layer MLP scorer
39
+ - **Training**: Pairwise ranking loss (`margin βˆ’ (score_relevant βˆ’ score_distractor)`, margin=5.0)
40
+ - **Dataset**: MS-MARCO v1.1 passage ranking, 79,704 train queries
41
+ - **Steps**: 1000, lr=5e-5, batch=1, gradient accumulation=8
42
+ - **Hardware**: RTX 5070 (8 GB VRAM), ~19 min training
43
+
44
+ ## Scoring Contract
45
+
46
+ ```python
47
+ # Passage scored with query context (query + passage in same forward pass)
48
+ # Token scores aggregated by arithmetic mean (high-first)
49
+ # Score space: sigmoid(MLP_output) ∈ [0, 1]
50
+ # Direction: descending (high score = more relevant) β€” established by supervised loss
51
+ ```
52
+
53
+ ## Checkpoint Structure
54
+
55
+ ```
56
+ tis_components.pt:
57
+ importance_head β†’ QueryAwareImportanceHead state dict
58
+ importance_embedding β†’ token embedding bias (from base architecture)
59
+ attn_hook_lambda β†’ attention hook weight
60
+ ```
61
+
62
+ ## Usage
63
+
64
+ ```python
65
+ import torch
66
+ from token_importance.model.patched_model import PatchedCausalLM
67
+ from token_importance.model.importance_head import QueryAwareImportanceHead
68
+
69
+ # Load checkpoint
70
+ ckpt = torch.load("tis_components.pt", map_location="cpu", weights_only=True)
71
+ model.importance_head.load_state_dict(ckpt["importance_head"])
72
+
73
+ # Score passage given query
74
+ def score_passage(model, tokenizer, query, passage, device="cuda"):
75
+ text = f"{query}\n\nPassage: {passage}"
76
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512).to(device)
77
+ with torch.no_grad():
78
+ out = model._base_model(**inputs, output_hidden_states=True)
79
+ hidden = out.hidden_states[-1]
80
+ # Split query / passage at separator
81
+ sep = inputs["input_ids"][0].tolist().index(28712) # '\\n\\n' token
82
+ query_h = hidden[:, :sep, :]
83
+ passage_h = hidden[:, sep:, :]
84
+ scores = model.importance_head(doc_hidden=passage_h, query_embeddings=query_h)
85
+ return scores.mean().item() # mean aggregation, descending = more relevant
86
+ ```
87
+
88
+ ## Reproduction
89
+
90
+ ```bash
91
+ git clone https://github.com/nitroxido/token-importance-scoring.git
92
+ cd token-importance-scoring
93
+ pip install -e .
94
+
95
+ # Download this checkpoint
96
+ hf download oldman-dev/tis-v2.2-passage-reranker --local-dir checkpoints/v2.2_query_aware_mean
97
+
98
+ # Evaluate (requires data/msmarco_relevance/test.parquet)
99
+ python scripts/evaluate_test_set_v2.2.py \
100
+ --checkpoint checkpoints/v2.2_query_aware_mean/final/tis_components.pt \
101
+ --data-path data/msmarco_relevance/test.parquet
102
+ ```
103
+
104
+ Full results: [`results/v2.2_test_final_results.json`](https://github.com/nitroxido/token-importance-scoring/blob/main/results/v2.2_test_final_results.json)
105
+
106
+ ## Checkpoint Identity
107
+
108
+ | Field | Value |
109
+ |---|---|
110
+ | SHA-256 (tis_components.pt) | `d26012b28d10b22c5f9c7260b3125ae0c001eb1ef701fef10266fbdc60ea576b` |
111
+ | Source commit | [fb04cbc](https://github.com/nitroxido/token-importance-scoring/commit/fb04cbc) |
112
+ | Base model | unsloth/mistral-7b-instruct-v0.3-bnb-4bit |
113
+ | Training objective | Pairwise ranking (is_selected labels, margin=5.0) |
114
+
115
+ ## Related Checkpoints
116
+
117
+ | Checkpoint | Task | Notes |
118
+ |---|---|---|
119
+ | [tis-stage3-ert](https://huggingface.co/oldman-dev/tis-stage3-ert) | KV compression + LITM | ERT trained; context-utility signal |
120
+ | [tis-v8b-hard-anchor](https://huggingface.co/oldman-dev/tis-v8b-hard-anchor) | NIAH 82% @ 25% budget | Best KV compression |
121
+ | [tis-passage-reranker](https://huggingface.co/oldman-dev/tis-passage-reranker) | LITM elimination | TIS 2.0; LITM gap 0.000 |
122
+
123
+ ## License
124
+
125
+ MIT β€” see [repository](https://github.com/nitroxido/token-importance-scoring).