# OTaT: One Token at a Time
Vision-Language Model Interpretability Analysis toolkit for analyzing attention patterns in models like LLaVA and Qwen-VL.

## Installation

### From PyPI
```bash
pip install otat
```

### From GitHub
```bash
pip install git@github.com:varungupta31/otat_api.git
```

### Local Development
```bash
git clone https://github.com/varungupta31/otat_api.git
cd otat_api
pip install -e .
```

## Quick Start
```python
from interpretability.api.wrapper import InterpretabilityAnalyzer

# Initialize analyzer for LLaVA OneVision 0.5B
analyzer = InterpretabilityAnalyzer(
    model_type="llava_onevision",
    model_id="llava-hf/llava-onevision-qwen2-0.5b-ov-hf",
    device='cuda:1' #or 'auto' or whichever device you wish to load the model on.
)

# Initialize analyzer for LLaVA OneVision 7B
analyzer = InterpretabilityAnalyzer(
    model_type="llava_onevision",
    model_id="llava-hf/llava-onevision-qwen2-7b-ov-hf",
    device='auto'
)

# Initialize analyzer for Qwen2.5-VL 3B
analyzer = InterpretabilityAnalyzer(
    model_type="qwen_25_vl",
    model_id="Qwen/Qwen2.5-VL-3B-Instruct"
    device='auto'
)

# Initialize analyzer for Qwen2.5-VL 7B
analyzer = InterpretabilityAnalyzer(
    model_type="qwen_25_vl",
    model_id="Qwen/Qwen2.5-VL-7B-Instruct"
    device='auto'
)

# Run analysis
result = analyzer.analyze(
    image_path="path/to/image.jpg",
    task_text="What is in this image?",
    instruction="Answer briefly.",
    blocking_mode="none",
    num_tokens=25
)

print(result['output_tokens'])
print(result['series'])  # Attention patterns
```

## Features

- 🔍 Attention pattern analysis for VLMs
- 🎯 Support for LLaVA, Qwen-VL, and Qwen2-LLM
- 🚫 Attention blocking experiments
- 📊 Token-level attention aggregation