DocSEAM: Bidirectional Cross-Page Encoding for Multi-Page Document Understanding

Hoang-Nhat Nguyen1  Β·  Chen Change Loy1,2

1S-Lab, Nanyang Technological University, Singapore  Β·  2Synvo AI

Project page arXiv paper Hugging Face model GitHub code

DocSEAM enriches visual features with context from neighboring pages for multi-page document understanding, preserving the visual token count.

DocSEAM overview showing cross-page feature enrichment and benchmark results

Introducing DocSEAM

DocSEAM enriches each page's visual features with information from its immediate neighbors through center-anchored masked attention and directional salience gates. It preserves the visual token count passed to the language model.

The architecture below details the directional gates and anchored attention mask used to enrich the center page.

DocSEAM architecture with directional gates and anchored attention masking

This repository contains the complete BF16 DocSEAM inference checkpoint in six safetensors shards. It incorporates the trained cross-page encoder, merged language-model adaptation, and trained vision merger.

Run with Transformers

Install the dependencies in requirements.txt. Select a CUDA device with enough memory for the BF16 weights and the document's activations and cache. Peak memory increases with the number and resolution of pages.

from pathlib import Path

import torch
from huggingface_hub import hf_hub_download
from qwen_vl_utils import process_vision_info
from transformers import AutoModelForImageTextToText, AutoProcessor

model_path = "mossbee/DocSEAM"
processor = AutoProcessor.from_pretrained(model_path)
model = AutoModelForImageTextToText.from_pretrained(
    model_path, dtype=torch.bfloat16, device_map={"": "cuda:0"}, trust_remote_code=True
)

page_paths = [
    hf_hub_download(model_path, f"examples/attention/1706.03762v7_page-{page:04d}.jpg")
    for page in (4, 5, 6)
]
question = "How many parallel attention heads are used in the model? Answer with only the number."
pages = [
    {"type": "image", "image": f"file://{Path(path).resolve()}",
     "min_pixels": 32768, "max_pixels": 524288}
    for path in page_paths
]
messages = [{"role": "user", "content": [*pages, {"type": "text", "text": question}]}]
prompt = processor.apply_chat_template(
    messages, tokenize=False, add_generation_prompt=True, enable_thinking=False
)
images, _ = process_vision_info(messages, image_patch_size=processor.image_processor.patch_size)
inputs = processor(text=[prompt], images=images, return_tensors="pt").to(model.device)
tokenizer = processor.tokenizer
with torch.inference_mode():
    tokens = model.generate(
        **inputs, max_new_tokens=128, do_sample=False,
        eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.pad_token_id,
    )
print(processor.decode(tokens[0, inputs.input_ids.shape[1]:], skip_special_tokens=True))

The example downloads pages 4–6 of Attention Is All You Need from this repository. For a local model checkout, use its path as model_path and pass the three local image paths directly in page_paths.

trust_remote_code=True loads the DocSEAM architecture from modeling_docseam.py and docseam.py in this model repository.

Cross-page attention

Cross-page attention on neighboring document pages

License

DocSEAM is released under the S-Lab License 1.0 for non-commercial use. The Qwen3.5-9B backbone's Apache-2.0 license is retained in LICENSE-QWEN.

Citation

@article{nguyen2026docseam,
  title={DocSEAM: Bidirectional Cross-Page Encoding for Multi-Page Document Understanding},
  author={Nguyen, Hoang-Nhat and Loy, Chen Change},
  journal={arXiv preprint arXiv:2611.34420},
  year={2026},
}
Downloads last month
-
Safetensors
Model size
10B params
Tensor type
BF16
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for mossbee/DocSEAM

Finetuned
Qwen/Qwen3.5-9B
Finetuned
(1,578)
this model

Space using mossbee/DocSEAM 1

Paper for mossbee/DocSEAM