Practical overview
When it fits
Use it when you have tokenized document collections in memory-mapped form and want to experiment with Marge-style evidence-based reconstruction during pretraining.
Who it is for
- Researchers exploring document-level pretraining objectives.
- Developers training encoder-decoder models on collections of tokenized documents.
Documented uses
- Train a model to reconstruct target documents from retrieved evidence documents.
- Experiment with paraphrase-based pretraining as an alternative to masked language modeling.
- Configure evidence and target documents from either the same collection or separate memory-mapped datasets.
- Generate samples from the decoder conditioned on evidence documents.
Requirements & limits
The repository is public and specifies an MIT license. The README documents installation with pip.
- The input preparation requirement is explicit: documents must be tokenized and stored as memory-mapped arrays.
- Evidence retrieval is part of the training workflow, with a configurable number of evidence documents and periodic reindexing.
- FAISS approximate-neighbor search can be disabled for collections where it is not needed.
- The README marks attention distillation as experimental and disabled by default.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Set up a Marge training workflow
Install the package and prepare the documented model, data wrapper, and training loop.
Before you start
- Python environment with PyTorch, NumPy, and the PyTorch DataLoader available.
- Tokenized documents stored as memory-mapped arrays shaped by document count and sequence length; masks can be supplied in a corresponding memory-mapped array.
- The documented example uses a vocabulary size, sequence length, model dimensions, and number of documents that must be adapted to the dataset.
Steps
Install the package with the command below.
pip install marge-pytorchCreate a
Margemodel with parameters for vocabulary size, maximum sequence length, encoder and decoder depth, attention heads, and feed-forward dimensions.Pass the model and memory-mapped document and mask paths to
TrainingWrapper, specifying document count, sequence length, and number of evidence documents.Create a PyTorch
DataLoaderfromtrainer.dataset; for each batch, call the trainer, backpropagate the loss, and perform the optimizer step.Call
trainer.reindex()at suitable intervals, as in the README example, which reindexes every 10,000 steps.
Expected outcome
A configured training loop for learning to reconstruct target documents from retrieved evidence documents.
Guide limitations
- The README does not specify a complete optimizer configuration or provide a real training corpus.
- Input documents must already be tokenized and arranged in memory-mapped files.
- Approximate-neighbor retrieval can be disabled with
use_faiss_ann=Falsewhen it is not needed for a small document collection.
Configure separate evidence and target document sets
Point the training wrapper at distinct memory-mapped files for evidence documents and target documents.
Before you start
- Evidence documents and target documents stored in separate memory-mapped arrays.
- Target documents use the same sequence length as the evidence documents.
- Optional corresponding memory-mapped mask files for each set.
Steps
Set the wrapper’s document and mask paths to the evidence arrays.
Pass
num_targetsandtarget_seq_lenfor the target collection.Set
target_memmap_pathand, if used,target_masks_memmap_pathto the target arrays.
Expected outcome
A `TrainingWrapper` configured to draw evidence and target documents from separate sets.
Guide limitations
- The README documents the wrapper configuration but does not provide a separate end-to-end training example for this setup.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 18 October 2026
- Original website title
- lucidrains/marge-pytorch · Official homepage title · retained in its source language

