Instructions to use mossbee/DocSEAM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mossbee/DocSEAM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="mossbee/DocSEAM", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("mossbee/DocSEAM", trust_remote_code=True) model = AutoModelForImageTextToText.from_pretrained("mossbee/DocSEAM", trust_remote_code=True, device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mossbee/DocSEAM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mossbee/DocSEAM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mossbee/DocSEAM", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/mossbee/DocSEAM
- SGLang
How to use mossbee/DocSEAM with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mossbee/DocSEAM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mossbee/DocSEAM", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mossbee/DocSEAM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mossbee/DocSEAM", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use mossbee/DocSEAM with Docker Model Runner:
docker model run hf.co/mossbee/DocSEAM
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
DocSEAM enriches visual features with context from neighboring pages for multi-page document understanding, preserving the visual token count.
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.
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
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
- -
Install from pip and serve model
# Install vLLM from pip: pip install vllm# Start the vLLM server: vllm serve "mossbee/DocSEAM"# Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mossbee/DocSEAM", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'