A benchmark for testing multimodal LLM spatial reasoning capabilities through iterative jigsaw puzzle solving.
๐ฎ โ Try it yourself - The puzzle that challenges frontier VLMs
Can frontier LLMs solve jigsaw puzzles? We tested GPT-5.2, Gemini 3 Pro, and Claude Opus 4.5 across grid sizes from 3ร3 to 5ร5 on 20 hand-picked images.
| Grid | Pieces | GPT-5.2 | Gemini 3 Pro | Claude Opus 4.5 |
|---|---|---|---|---|
| 3ร3 | 9 | 95% solve, 97% acc | 85% solve, 93% acc | 20% solve, 47% acc |
| 4ร4 | 16 | 40% solve, 77% acc | 25% solve, 72% acc | - |
| 5ร5 | 25 | 0% solve, 46% acc | 10% solve, 49% acc | - |
Solve = fully completed puzzles. Acc = % of pieces in correct position.
Key insights:
- ๐ด Difficulty scales steeply - solve rates crash from 95% to 0% between 3ร3 and 5ร5
- ๐ด No model reliably solves 5ร5 - spatial reasoning hits a wall at 25 pieces
- ๐ก Partial progress is common - models often hit a wall at 50-80% piece accuracy for 4x4 and 5x5
GPT-5.2 and Gemini 3 Pro tested with low reasoning effort; Claude Opus 4.5 with high. Higher reasoning showed slightly better performance on individual images, but both GPT-5.2 and Gemini 3 Pro would still get stuck at around 50-70% piece accuracy on average for 5x5 grid sizes.
All models received the reference image, correct piece count, and last 3 moves as context.
๐ Detailed benchmark results
This project shuffles an image into an NรN grid and challenges an LLM to restore the original image by iteratively swapping pieces. The task tests:
- Visual understanding: Recognizing piece content and how pieces fit together
- Spatial reasoning: Understanding grid coordinates and piece relationships
- Iterative problem solving: Making progress across multiple turns
- Memory/context: Tracking previous moves and learning from them
- Configurable difficulty: Square (4ร4) or rectangular (3ร5) grids
- Multiple LLM providers: OpenAI, Anthropic, Google
- Visual annotations: Grid labels, colored borders for easy piece identification
- Comprehensive metrics: Tracks moves, accuracy, tokens, timing
- Reproducible: Seed-based shuffling for consistent benchmarks
- Optional hints: Show correct count, provide reference image
- Animated GIF output: Visualize the solving process
# Clone the repository
git clone https://github.com/yourusername/llm-jigsaw.git
cd llm-jigsaw
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt# Set your API key
export OPENAI_API_KEY="your-key-here"
export GOOGLE_API_KEY="your-key-here"
export ANTHROPIC_API_KEY="your-key-here"
# Run a simple puzzle
python main.py --image images/sample.jpg --resize 512 --grid-size 3 --model openai/gpt-5.2๐ Full CLI reference ยท Benchmark guide
Test multiple models across many images:
python benchmark.py \
--models openai/gpt-5.2 google/gemini-3-pro-preview \
--image-folder images \
--grid-size 4 \
--reasoning-effort low \
--resize 768 \
--parallel๐ Full benchmark guide
The LLM receives the shuffled puzzle image and responds with JSON specifying swaps:
{
"reasoning": "The sky piece at 1,3 belongs at 1,1 based on color continuity",
"moves": [
{"op": "swap", "a": "1,1", "b": "1,3"},
{"op": "swap", "a": "2,4", "b": "4,2"}
]
}Coordinates use 1-indexed "row,col" format (top-left is "1,1").
Results are saved to the output directory:
results/run_name/
โโโ result.json # Complete metrics and move history
โโโ initial_state.png # Shuffled puzzle at start
โโโ final_state.png # Puzzle state at end
โโโ game.gif # Animated solving process
llm-jigsaw/
โโโ src/ # Core library
โ โโโ benchmark/ # Benchmark framework
โ โโโ image_processor.py # Image slicing and state management
โ โโโ grid_annotator.py # Visual annotations
โ โโโ llm_interface.py # LLM API abstraction
โ โโโ game.py # Game controller
โ โโโ prompts.py # Prompt templates
โโโ streamlit_app/ # Human player web app
โ โโโ app.py # Streamlit app
โ โโโ requirements_app.txt # App dependencies
โโโ docs/ # Documentation
โ โโโ RESULTS.md # Benchmark results
โ โโโ BENCHMARK.md # Benchmark guide
โ โโโ USAGE.md # CLI usage guide
โโโ tests/ # Test suite
โโโ images/ # Test images
โโโ main.py # CLI entry point
โโโ benchmark.py # Benchmark runner
MIT License