Views
No views yet
| Model | MARSv2 | Notes |
|---|---|---|
| baseline (merged input, non-shared) | ~52 | original reference |
| shared cross-attention (this model) | 57.02 | best single model, 2L × 3 epochs |
| 4-way ensemble (1L+2L+6L+baseline) | ~59.0 | aggregate champion |
answerdotai/ModernBERT-base encoder (149M params), shared between
the summary and the masked-text streams.model.pt, ~770 MB fp32).[ENTMASK] — generic mask[ENTSTART] / [ENTEND] — multi-token entity boundaries[ENTMASK_<TYPE>] for 18 spaCy NER types: PERSON, ORG, GPE, LOC, DATE, TIME, MONEY, QUANTITY, PERCENT, CARDINAL, ORDINAL, EVENT, WORK_OF_ART, LAW, LANGUAGE, FAC, PRODUCT, NORPpip install transformers torch huggingface_hubmodeling_mars.py and
inference.py (they are not auto-loaded by AutoModel because the
architecture is custom).1from inference import MarsInference
2
3inf = MarsInference("Glazkov/mars-shared-cross-attention-modernbert")
4
5summary = (
6 "The president announced a new climate policy in Washington on Tuesday, "
7 "promising to cut emissions by 40% by 2030."
8)
9masked_text = (
10 "<mask> announced a new climate policy in <mask> on <mask>, "
11 "promising to cut emissions by <mask> by <mask>."
12)
13entity_types = ["PERSON", "GPE", "DATE", "PERCENT", "DATE"]
14
15predictions, confidences = inf.predict(
16 summary, masked_text,
17 entity_types=entity_types,
18 return_confidence=True,
19)
20for t, p, c in zip(entity_types, predictions, confidences):
21 print(f" [{t}] -> {p!r} (conf={c:.2f})")1from modeling_mars import load_model_from_checkpoint
2
3model, tokenizer, device = load_model_from_checkpoint(
4 "Glazkov/mars-shared-cross-attention-modernbert"
5)
6
7# Both inputs go through the SAME encoder; the masked stream cross-attends
8# to the summary stream via the 2 cross-attention layers.
9summary_enc = tokenizer("the summary text", return_tensors="pt").to(device)
10masked_enc = tokenizer(
11 "the original text with [ENTSTART] [ENTMASK_PERSON] removed",
12 return_tensors="pt",
13).to(device)
14
15with torch.no_grad():
16 out = model(
17 summary_input_ids=summary_enc["input_ids"],
18 summary_attention_mask=summary_enc["attention_mask"],
19 masked_input_ids=masked_enc["input_ids"],
20 masked_attention_mask=masked_enc["attention_mask"],
21 )
22logits = out.logits # [batch, seq_len, vocab]1import spacy
2import re
3
4nlp = spacy.load("en_core_web_sm")
5
6def mask_entities(text: str):
7 doc = nlp(text)
8 masked, types, golds = text, [], []
9 # iterate in reverse so character offsets remain valid
10 for ent in sorted(doc.ents, key=lambda e: -e.start_char):
11 masked = masked[:ent.start_char] + "<mask>" + masked[ent.end_char:]
12 types.insert(0, ent.label_)
13 golds.insert(0, ent.text)
14 return masked, types, golds
15
16article = "..."
17summary = "..."
18
19masked_text, types, gold = mask_entities(article)
20preds = inf.predict(summary, masked_text, entity_types=types)
21recall = sum(p.lower() == g.lower() for p, g in zip(preds, gold)) / max(1, len(gold))
22print(f"Entity recall: {recall:.2%}")en_core_web_sm NER and replaced with
typed mask tokens. The model was trained for 3 epochs at LR 5e-5,
batch size 8, on a single A100 (~24 h wall time).1@misc{mars2026,
2 title = {MARS: Masked Accuracy Recovery Score for Summarization},
3 author = {Glazkov, Nikita},
4 year = {2026},
5 url = {https://huggingface.co/Glazkov/mars-shared-cross-attention-modernbert}
6}