Skip to main content
Back

PuzLM Solves Jigsaw Puzzles Without Ever Seeing a Single Pixel

Researchers at Ben-Gurion University turn jigsaw pieces into discrete tokens and let a BART model solve the puzzle, beating vision-based solvers.

Pro

  • PuzLM reframes jigsaw solving as sequence-to-sequence prediction, using discrete tokens instead of pixel features. Paper
  • Tokenizer uses PCA plus k-means on border patches, producing super-tokens under 1M parameters and 1ms per piece.
  • Achieves 92.2% absolute and 87.1% perfect accuracy on ImageNet 3x3, beating FCViT by 8.2 points on perfect solves.
  • On JPwLEG-5 with eroded boundaries, PuzLM improves perfect accuracy by 13.5 points over prior state of the art.
  • BART backbone works best; RNNs and decoder-only LVLM approaches significantly underperform on the task.
  • Statistical analysis shows tokenized puzzles follow Zipf and Heaps laws similar to natural language corpora.

Solving square jigsaw puzzles has been a computer vision problem for six decades, and the recipe has stayed mostly the same: extract visual features from each piece, compute pairwise compatibilities, and search for a globally consistent layout. A new paper called PuzLM throws that playbook out. Instead of comparing pixels, it converts every piece into a short string of discrete tokens and hands the whole thing to a standard encoder-decoder language model, treating jigsaw reassembly like a machine translation task.

The surprising part is that this purely symbolic reasoning over discrete representations improves state-of-the-art performance even on puzzles with eroded boundaries or missing pieces. The model never sees pixels during solving. It just moves tokens around.

PuzLM pipeline overview showing tokenization and Seq2Seq prediction

Why the old approach hit a wall

Square puzzles are harder than the ones you buy at a toy store because unlike commercial toy puzzles with uniquely shaped pieces, square puzzles lack geometric cues that could guide reconstruction, forcing solvers to rely primarily on their visual content. Every existing deep-learning solver, whether it uses CNNs, GANs, diffusion, reinforcement learning, or Vision Transformers, works on raw pixels or learned visual embeddings. That coupling makes it impossible to tell whether success comes from local pixel matching or from higher-level structural reasoning about the layout as a whole.

The PuzLM authors argue that this ambiguity has hidden something important. If you strip out visual access entirely and force a model to reason only about abstract symbols, can it still put the puzzle back together? The answer, apparently, is yes, and often better than the pixel-based competition.

How the tokenizer works

The quantization procedure is deliberately lightweight. There is no VQ-VAE, no learned codebook, no encoder network. It runs in four steps:

  1. Patch extraction: each puzzle piece is split into a B×B grid of sub-patches (the paper uses B=4).
  2. PCA projection: patches are flattened and projected into a lower-dimensional space to strip out irrelevant visual variance before clustering.
  3. k-means clustering: each patch gets assigned to its nearest centroid, and the centroid index becomes its token. The number of centroids k defines vocabulary size (4096 in the main experiments).
  4. Border selection: only the boundary patches survive. The b = max(1, 4B-4) tokens located on the borders of each piece are concatenated in clockwise order to form a super-token: a short discrete sequence that represents one piece. Interior patches get discarded because they carry no information about how pieces connect.

Super-tokens for all pieces are then concatenated in lexicographic order with a [SEP] token between them, exactly like words in a sentence. A puzzle becomes a sequence, and a solution becomes a permutation of grid indices, which is what the decoder autoregressively predicts.

Tokenization pipeline: patches, PCA, k-means, border selection

Why an encoder-decoder specifically

The choice of architecture is deliberate. Encoder-only ViT approaches have to predict every piece placement simultaneously and often need auxiliary constraints to avoid conflicts. Decoder-only setups (used by recent LVLM jigsaw attempts) treat output as a continuation of input under one shared distribution, which does not fit a task where inputs are tokens and outputs are grid indices. The autoregressive formulation decomposes the combinatorial permutation space into conditional decisions, substantially simplifying inference compared to predicting the entire assignment in a single step. Notably, the model learns on its own not to assign two pieces to the same slot, without any specialized decoding constraint.

For the backbone, the authors tried LSTM, GRU, T5, Pegasus, and BART. BART won across sizes, and RNNs got crushed, confirming that global attention matters a lot for holding a whole puzzle in mind.

The numbers

On the classic ImageNet 3x3 benchmark, PuzLM hits 92.2 absolute and 87.1 perfect accuracy, beating FCViT's 90.6/78.9. The perfect-accuracy jump of 8.2 points is the interesting one because that metric requires every single piece to land correctly.

Things get more dramatic on harder benchmarks:

  • JPwLEG-5 (5x5 puzzles with eroded artwork boundaries): 72.1 absolute, 32.5 perfect, compared with 66.9 and 19.0 for the previous best vision-language method. That is a +13.5 point gain in perfect solutions.
  • ImageNet 3x3 with missing pieces: with three of nine pieces gone, PuzLM hits 61.2 absolute versus 54.1 for JPDVT, and 23.7 perfect versus 14.9.
  • Tokenizer comparison: the humble PCA plus k-means pipeline crushes VQ-VAE (34.4 abs) and every TiTok variant (up to 641M parameters, still only 41.9 abs). PuzLM's tokenizer has under 1M parameters and runs in under 1ms per piece.

The tokenizer's ablations reveal that removing PCA drops accuracy by about 10 points, using non-border patches drops it 20 points, and using random rather than lexicographic ordering drops it 24 points. Every design choice earns its keep.

Comparison of Seq2Seq backbones LSTM, GRU, Pegasus, T5, BART

The deeper finding

Beyond the leaderboard numbers, the paper does a corpus-linguistics analysis on the token streams and finds that tokenized puzzles follow structure similar to natural language: Shannon entropy well below the uniform ceiling, a partial Zipfian frequency distribution, and Heaps-like vocabulary growth. Puzzle pieces, once discretized, statistically behave a bit like words, which is why standard NLP architectures trained from scratch on these sequences work so well.

The real breakthrough here is not the leaderboard win but the demonstration that a combinatorial spatial-reasoning problem long thought to require vision-specific feature learning can be handled by a general Seq2Seq model working purely on symbols. It hints that other structured vision problems (document reassembly, satellite mosaicing, fragment reconstruction for archaeology) might yield to similar treatment.

Where it falls short

PuzLM is not a universal jigsaw solver yet. On JPwLEG-3, it still trails FCViT (91.9 vs 96.9 absolute), suggesting vision-based methods retain an edge when pieces are small and boundaries are clean enough. The tokenizer has to be trained per dataset, and the vocabulary is not transferable across image domains without retraining k-means. The paper does not release code as of the current preprint, though the method is simple enough to reimplement in a weekend given standard BART checkpoints and scikit-learn.