Image-Text-to-Text
Transformers
Safetensors
qwen3_5
document-question-answering
multi-page-documents
custom_code
conversational
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
|
Download README.md from mossbee/DocSEAM: direct link, hf CLI and curl.
- Browser
- Download file 5.19 kB
-
https://huggingface.co/mossbee/DocSEAM/resolve/main/README.md
- Command line
-
hf download hf://mossbee/DocSEAM/README.md
-
curl -L -o README.md https://huggingface.co/mossbee/DocSEAM/resolve/main/README.md
5.19 kB
| license: other | |
| license_name: slab | |
| license_link: LICENSE | |
| library_name: transformers | |
| pipeline_tag: image-text-to-text | |
| base_model: Qwen/Qwen3.5-9B | |
| tags: | |
| - document-question-answering | |
| - multi-page-documents | |
| - custom_code | |
| <div align="center"> | |
| <h2>DocSEAM: Bidirectional Cross-Page Encoding for Multi-Page Document Understanding</h2> | |
| <p> | |
| <a href="https://mossbee.github.io/">Hoang-Nhat Nguyen</a><sup>1</sup> · | |
| <a href="https://www.mmlab-ntu.com/person/ccloy/">Chen Change Loy</a><sup>1,2</sup> | |
| </p> | |
| <p> | |
| <sup>1</sup>S-Lab, Nanyang Technological University, Singapore · <sup>2</sup><a href="https://synvo.ai/">Synvo AI</a> | |
| </p> | |
| <p> | |
| <a href="https://mossbee.github.io/projects/DocSEAM/"><img src="https://img.shields.io/badge/%F0%9F%8C%90-Project_Page-267CB9" alt="Project page"></a> | |
| <a href="https://arxiv.org/abs/2611.34420"><img src="https://img.shields.io/badge/arXiv-Paper-B31B1B?logo=arxiv&logoColor=white" alt="arXiv paper"></a> | |
| <a href="https://huggingface.co/mossbee/DocSEAM"><img src="https://img.shields.io/badge/%F0%9F%A4%97-Hugging_Face-FFD21E" alt="Hugging Face model"></a> | |
| <a href="https://github.com/mossbee/DocSEAM"><img src="https://img.shields.io/badge/GitHub-Code-181717?logo=github&logoColor=white" alt="GitHub code"></a> | |
| </p> | |
| </div> | |
| <p align="center"><strong>DocSEAM enriches visual features with context from neighboring pages for multi-page document understanding, preserving the visual token count.</strong></p> | |
| <p align="center"> | |
| <img src="assets/overview.jpg" width="100%" alt="DocSEAM overview showing cross-page feature enrichment and benchmark results"> | |
| </p> | |
| <details> | |
| <summary><b>Introducing DocSEAM</b></summary> | |
| <p>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.</p> | |
| <p>The architecture below details the directional gates and anchored attention mask used to enrich the center page.</p> | |
| <p align="center"> | |
| <img src="assets/architecture.jpg" width="100%" alt="DocSEAM architecture with directional gates and anchored attention masking"> | |
| </p> | |
| </details> | |
| 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. | |
| ```python | |
| 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 | |
| <p align="center"> | |
| <img src="assets/attention.jpg" width="100%" alt="Cross-page attention on neighboring document pages"> | |
| </p> | |
| ## License | |
| DocSEAM is released under the [S-Lab License 1.0](LICENSE) for non-commercial use. The Qwen3.5-9B backbone's Apache-2.0 license is retained in [LICENSE-QWEN](LICENSE-QWEN). | |
| ## Citation | |
| ```bibtex | |
| @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}, | |
| } | |
| ``` | |