# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
A benchmark for evaluating vision-capable LLMs on Indian competitive exam questions (JEE Main, JEE Advanced, NEET). Questions are images sent to models via the OpenRouter API; responses are parsed from `...` tags and scored using exam-specific marking schemes.
## Running the Benchmark
```bash
# Setup
uv sync
echo "OPENROUTER_API_KEY=your_key" > .env
# Must run from project root (paths are resolved relative to cwd)
uv run python src/benchmark_runner.py --model "google/gemini-2.5-pro-preview-03-25" --exam_name JEE_ADVANCED --exam_year 2025
# Filter by question IDs
uv run python src/benchmark_runner.py --model "openai/o3" --question_ids "N24T3001,N24T3002"
```
CLI args: `--model` (required), `--exam_name` (all/NEET/JEE_ADVANCED/JEE_MAIN), `--exam_year` (all/2024/2025), `--question_ids`, `--output_dir`, `--config`, `--resume`.
## Testing
```bash
# Run the full pytest suite (68 tests)
uv run pytest tests/ -v
# Run individual module self-tests
uv run python src/utils.py # answer parsing logic
uv run python src/evaluation.py # scoring logic
uv run python src/llm_interface.py # API calls (requires .env and network)
```
## Architecture
```
benchmark_runner.py ─── orchestrator / entry point
├── loads config from configs/benchmark_config.yaml
├── loads dataset directly from metadata.jsonl (JSONL → HuggingFace Dataset)
│ ├── metadata.jsonl (question metadata, 578 questions)
│ └── images/ (question PNGs, stored in Git LFS)
├── calls llm_interface.py for each question
│ ├── prompts.py (prompt templates)
│ └── utils.py (parse_llm_answer extracts from tags)
├── scores via evaluation.py (exam-specific marking schemes)
└── writes results incrementally to results/{model}_{exam}_{year}_{timestamp}/
├── predictions.jsonl (raw API responses)
├── summary.jsonl (scored per-question results)
└── summary.md (human-readable report)
```
### Key data flow
1. Dataset loaded directly from `metadata.jsonl` into a HuggingFace `Dataset` object, filtered by exam/year
2. Each question image is base64-encoded and sent to OpenRouter with a structured prompt
3. If the response can't be parsed, a re-prompt is sent (text-only, with the bad response)
4. If the API call fails, the question is queued for retry (up to 3 attempts, exponential backoff via `tenacity`)
5. Answers are parsed from `...` tags by `utils.parse_llm_answer()`
6. `evaluation.py` scores using JEE/NEET marking schemes (partial credit for MCQ_MULTIPLE_CORRECT in JEE Advanced)
## Answer Format Conventions
- `MCQ_SINGLE_CORRECT`: `A` → `["A"]`
- `MCQ_MULTIPLE_CORRECT`: `A,C` → `["A", "C"]` (sorted, deduplicated)
- `INTEGER`: `42` → `["42"]`
- `SKIP`: `SKIP` → no penalty
## Important Notes
- **Git LFS**: Images and `metadata.jsonl` are in LFS. Run `git lfs pull` after cloning.
- **Working directory**: Scripts must be run from project root — config, data, and image paths are resolved relative to cwd.
- **Python 3.10+**: Uses union type syntax (`list[str] | str | None`).
- **Models**: Configured in `configs/benchmark_config.yaml` under `openrouter_models`. All must support vision input.
- **Result directory naming**: `results/{provider}_{model}_{exam}_{year}_{YYYYMMDD_HHMMSS}/` (slashes in model IDs replaced with underscores).