lookagain 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lookagain-0.1.0/LICENSE +21 -0
- lookagain-0.1.0/PKG-INFO +500 -0
- lookagain-0.1.0/README.md +456 -0
- lookagain-0.1.0/pyproject.toml +89 -0
- lookagain-0.1.0/setup.cfg +4 -0
- lookagain-0.1.0/src/lookagain/__init__.py +3 -0
- lookagain-0.1.0/src/lookagain/cli.py +266 -0
- lookagain-0.1.0/src/lookagain/config.py +267 -0
- lookagain-0.1.0/src/lookagain/judge/__init__.py +6 -0
- lookagain-0.1.0/src/lookagain/judge/anthropic_judge.py +105 -0
- lookagain-0.1.0/src/lookagain/judge/base.py +35 -0
- lookagain-0.1.0/src/lookagain/judge/factory.py +64 -0
- lookagain-0.1.0/src/lookagain/judge/gemini_judge.py +107 -0
- lookagain-0.1.0/src/lookagain/judge/openai_judge.py +92 -0
- lookagain-0.1.0/src/lookagain/judge/prompts.py +56 -0
- lookagain-0.1.0/src/lookagain/models/__init__.py +6 -0
- lookagain-0.1.0/src/lookagain/models/anthropic_model.py +83 -0
- lookagain-0.1.0/src/lookagain/models/base.py +30 -0
- lookagain-0.1.0/src/lookagain/models/factory.py +37 -0
- lookagain-0.1.0/src/lookagain/models/gemini_model.py +63 -0
- lookagain-0.1.0/src/lookagain/models/http_model.py +77 -0
- lookagain-0.1.0/src/lookagain/models/openai_model.py +75 -0
- lookagain-0.1.0/src/lookagain/reporter.py +217 -0
- lookagain-0.1.0/src/lookagain/scenarios/__init__.py +16 -0
- lookagain-0.1.0/src/lookagain/scenarios/base.py +62 -0
- lookagain-0.1.0/src/lookagain/scenarios/corruption.py +124 -0
- lookagain-0.1.0/src/lookagain/scenarios/missing_image.py +136 -0
- lookagain-0.1.0/src/lookagain/scenarios/text_bias.py +82 -0
- lookagain-0.1.0/src/lookagain/scenarios/wrong_image.py +105 -0
- lookagain-0.1.0/src/lookagain/scorer.py +122 -0
- lookagain-0.1.0/src/lookagain/test_suite.py +184 -0
- lookagain-0.1.0/src/lookagain/utils/__init__.py +6 -0
- lookagain-0.1.0/src/lookagain/utils/embedding.py +126 -0
- lookagain-0.1.0/src/lookagain/utils/embedding_config.py +50 -0
- lookagain-0.1.0/src/lookagain/utils/image_utils.py +99 -0
- lookagain-0.1.0/src/lookagain/utils/logging_config.py +51 -0
- lookagain-0.1.0/src/lookagain.egg-info/PKG-INFO +500 -0
- lookagain-0.1.0/src/lookagain.egg-info/SOURCES.txt +43 -0
- lookagain-0.1.0/src/lookagain.egg-info/dependency_links.txt +1 -0
- lookagain-0.1.0/src/lookagain.egg-info/entry_points.txt +2 -0
- lookagain-0.1.0/src/lookagain.egg-info/requires.txt +19 -0
- lookagain-0.1.0/src/lookagain.egg-info/top_level.txt +1 -0
- lookagain-0.1.0/tests/test_missing_image.py +77 -0
- lookagain-0.1.0/tests/test_scorer_reporter.py +162 -0
- lookagain-0.1.0/tests/test_smoke.py +193 -0
lookagain-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LookAgain Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
lookagain-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lookagain
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: LookAgain: VLM Reliability Auditor -- test if your VLM truly relies on visual evidence.
|
|
5
|
+
Author: LookAgain Contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Fengrru/lookagain
|
|
8
|
+
Project-URL: Documentation, https://github.com/Fengrru/lookagain#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/Fengrru/lookagain
|
|
10
|
+
Project-URL: Issues, https://github.com/Fengrru/lookagain/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/Fengrru/lookagain/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: vlm,multimodal,reliability,audit,vision-language,hallucination,testing,benchmark,evaluation
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Topic :: Software Development :: Testing
|
|
24
|
+
Classifier: Operating System :: OS Independent
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: openai>=1.0
|
|
29
|
+
Requires-Dist: Pillow>=10.0
|
|
30
|
+
Requires-Dist: numpy>=1.24
|
|
31
|
+
Requires-Dist: PyYAML>=6.0
|
|
32
|
+
Provides-Extra: anthropic
|
|
33
|
+
Requires-Dist: anthropic>=0.30.0; extra == "anthropic"
|
|
34
|
+
Provides-Extra: gemini
|
|
35
|
+
Requires-Dist: google-generativeai>=0.7.0; extra == "gemini"
|
|
36
|
+
Provides-Extra: all
|
|
37
|
+
Requires-Dist: anthropic>=0.30.0; extra == "all"
|
|
38
|
+
Requires-Dist: google-generativeai>=0.7.0; extra == "all"
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
41
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
42
|
+
Requires-Dist: ruff>=0.5.0; extra == "dev"
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
|
|
45
|
+
<p align="center">
|
|
46
|
+
<h1 align="center">LookAgain</h1>
|
|
47
|
+
<p align="center">
|
|
48
|
+
<strong>Black-box Reliability Auditor for Vision-Language Models</strong>
|
|
49
|
+
</p>
|
|
50
|
+
<p align="center">
|
|
51
|
+
<a href="#installation">Installation</a> •
|
|
52
|
+
<a href="#quick-start">Quick Start</a> •
|
|
53
|
+
<a href="#documentation">Documentation</a> •
|
|
54
|
+
<a href="#contributing">Contributing</a> •
|
|
55
|
+
<a href="#license">License</a>
|
|
56
|
+
</p>
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
<p align="center">
|
|
60
|
+
<img src="https://img.shields.io/badge/version-0.1.0-blue.svg" alt="Version">
|
|
61
|
+
<img src="https://img.shields.io/badge/python-3.9+-green.svg" alt="Python">
|
|
62
|
+
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="License">
|
|
63
|
+
<img src="https://img.shields.io/badge/status-alpha-orange.svg" alt="Status">
|
|
64
|
+
</p>
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## What is LookAgain?
|
|
69
|
+
|
|
70
|
+
**LookAgain** is a black-box reliability auditor for Vision-Language Models (VLMs). It tests whether your VLM truly relies on visual evidence, or whether it answers based on text bias, stereotypes, or hallucination when images are missing, corrupted, or misleading.
|
|
71
|
+
|
|
72
|
+
> **Key Insight**: Unlike training-based hallucination mitigators, LookAgain treats the model as a black box and only uses API calls. This makes it ideal for auditing commercial VLMs (OpenAI, Anthropic, Google Gemini) and local deployments alike.
|
|
73
|
+
|
|
74
|
+
### Architecture
|
|
75
|
+
|
|
76
|
+
```mermaid
|
|
77
|
+
graph LR
|
|
78
|
+
A[CLI] --> B[Model Adapter]
|
|
79
|
+
B --> C[Test Scenarios]
|
|
80
|
+
C --> D[Scorer]
|
|
81
|
+
D --> E[Reporter]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Key Features
|
|
87
|
+
|
|
88
|
+
| Feature | Description |
|
|
89
|
+
|---------|-------------|
|
|
90
|
+
| **Black-box Testing** | No access to model weights required -- API-only evaluation |
|
|
91
|
+
| **Comprehensive Scenarios** | 4 test dimensions covering visual reliance, robustness, and bias |
|
|
92
|
+
| **Multi-provider Support** | OpenAI, Anthropic, Google Gemini, and OpenAI-compatible endpoints |
|
|
93
|
+
| **Unified Scoring** | Single 0-100 LookAgain Score with clear risk bands |
|
|
94
|
+
| **LLM-as-Judge** | Optional AI-powered answer evaluation for nuanced cases |
|
|
95
|
+
| **Multiple Reports** | Terminal, JSON, and Markdown output formats |
|
|
96
|
+
| **Dry-run Mode** | Estimate token usage and costs before running tests |
|
|
97
|
+
| **Configurable** | YAML/TOML/JSON config files + environment variables |
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Why LookAgain?
|
|
102
|
+
|
|
103
|
+
Enterprises deploying VLMs face a hard question: *does this model actually look at the image, or is it just guessing from the prompt?* LookAgain answers this with standardized, reproducible tests.
|
|
104
|
+
|
|
105
|
+
### Use Cases
|
|
106
|
+
|
|
107
|
+
- **Pre-deployment Validation** -- Verify VLM products before production rollout
|
|
108
|
+
- **Vendor Comparison** -- Score GPT-4o, Claude, Gemini, and open-source VLMs on the same benchmark
|
|
109
|
+
- **Regression Testing** -- Detect performance degradation after model updates
|
|
110
|
+
- **Compliance Reporting** -- Generate evidence for EU AI Act, NIST AI RMF frameworks
|
|
111
|
+
- **Research Benchmarking** -- Standardized evaluation for academic papers
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Test Scenarios
|
|
116
|
+
|
|
117
|
+
| Scenario | What It Checks | How It Works |
|
|
118
|
+
|----------|----------------|--------------|
|
|
119
|
+
| **Missing Image** | Does the model abstain when no image is provided, or does it fabricate visual details? | Rule-based detection + LLM-as-Judge |
|
|
120
|
+
| **Wrong Image** | Does the answer change appropriately when the image is swapped? | Embedding similarity comparison |
|
|
121
|
+
| **Image Corruption** | Is the model robust to blur, noise, and occlusion? | Corruption robustness curve (AUC) |
|
|
122
|
+
| **Text Bias** | Does misleading text cause the model to ignore the image? | LLM-as-Judge evaluation |
|
|
123
|
+
|
|
124
|
+
### Test Scenarios Overview
|
|
125
|
+
|
|
126
|
+
```mermaid
|
|
127
|
+
graph TB
|
|
128
|
+
subgraph "Missing Image"
|
|
129
|
+
A1[No Image] --> A2[Fabrication Detection]
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
subgraph "Wrong Image"
|
|
133
|
+
B1[Original] --> B2[Similarity Comparison]
|
|
134
|
+
B3[Wrong] --> B2
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
subgraph "Image Corruption"
|
|
138
|
+
C1[Original] --> C2[Robustness Measurement]
|
|
139
|
+
C3[Corrupted] --> C2
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
subgraph "Text Bias"
|
|
143
|
+
D1[Correct Image] --> D2[Bias Detection]
|
|
144
|
+
D3[Misleading Text] --> D2
|
|
145
|
+
end
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### LookAgain Score
|
|
149
|
+
|
|
150
|
+
The final **LookAgain Score** (0-100) combines these four dimensions:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
Score = 100 - (MissingImage * 0.35 + WrongImage * 0.30 + (100 - Corruption) * 0.15 + TextBias * 0.20)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
| Score Range | Risk Level | Recommendation |
|
|
157
|
+
|-------------|------------|----------------|
|
|
158
|
+
| 85-100 | LOW RISK | Model shows strong visual reliance |
|
|
159
|
+
| 60-84 | MODERATE RISK | Some visual reliance issues detected |
|
|
160
|
+
| 0-59 | HIGH RISK | Significant visual reliance problems |
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Supported Providers
|
|
165
|
+
|
|
166
|
+
| Provider | Models | Auth Method |
|
|
167
|
+
|----------|--------|-------------|
|
|
168
|
+
| **OpenAI** | GPT-4o, GPT-4V, GPT-4o-mini | `OPENAI_API_KEY` |
|
|
169
|
+
| **Anthropic** | Claude 3 Opus, Claude 3.5 Sonnet | `ANTHROPIC_API_KEY` |
|
|
170
|
+
| **Google Gemini** | gemini-1.5-flash, gemini-1.5-pro | `GOOGLE_API_KEY` |
|
|
171
|
+
| **HTTP/Local** | Any OpenAI-compatible endpoint | Custom base URL |
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Installation
|
|
176
|
+
|
|
177
|
+
### From Source (Recommended)
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
git clone https://github.com/Fengrru/lookagain.git
|
|
181
|
+
cd lookagain
|
|
182
|
+
pip install -e .
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### With All Providers
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
pip install -e ".[all]"
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Individual Providers
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
pip install -e ".[anthropic]" # Anthropic Claude
|
|
195
|
+
pip install -e ".[gemini]" # Google Gemini
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Requirements
|
|
199
|
+
|
|
200
|
+
- Python 3.9+
|
|
201
|
+
- OpenAI API key (for embedding similarity)
|
|
202
|
+
- Provider-specific API keys
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Quick Start
|
|
207
|
+
|
|
208
|
+
### 1. Generate Synthetic Test Images
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
python data/generate_images.py
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### 2. Set Your API Key
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
export OPENAI_API_KEY="sk-..."
|
|
218
|
+
# or
|
|
219
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
220
|
+
# or
|
|
221
|
+
export GOOGLE_API_KEY="..."
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### 3. Run an Audit
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# OpenAI GPT-4o
|
|
228
|
+
lookagain audit --provider openai --model gpt-4o
|
|
229
|
+
|
|
230
|
+
# Anthropic Claude
|
|
231
|
+
lookagain audit --provider anthropic --model claude-3-5-sonnet-20241022
|
|
232
|
+
|
|
233
|
+
# Google Gemini
|
|
234
|
+
lookagain audit --provider gemini --model gemini-1.5-flash
|
|
235
|
+
|
|
236
|
+
# Local vLLM / Ollama
|
|
237
|
+
lookagain audit --provider http --model Qwen2-VL-7B-Instruct --base-url http://localhost:8000/v1
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### 4. Example Output
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
$ lookagain audit --provider openai --model gpt-4o
|
|
244
|
+
|
|
245
|
+
LookAgain
|
|
246
|
+
Provider: openai
|
|
247
|
+
Model under test: gpt-4o
|
|
248
|
+
Judge provider: openai
|
|
249
|
+
Judge: gpt-4o
|
|
250
|
+
Output: ./lookagain_results
|
|
251
|
+
Formats: ['terminal', 'json', 'markdown']
|
|
252
|
+
|
|
253
|
+
Loading test cases...
|
|
254
|
+
[1/4] Running Missing Image tests...
|
|
255
|
+
12 tests, 2 failed
|
|
256
|
+
[2/4] Running Wrong Image tests...
|
|
257
|
+
14 tests, 3 failed
|
|
258
|
+
[3/4] Running Image Corruption tests...
|
|
259
|
+
12 tests, robustness score: 85.2%
|
|
260
|
+
[4/4] Running Text Bias tests...
|
|
261
|
+
12 tests, 4 failed
|
|
262
|
+
|
|
263
|
+
+------------------------------------------+
|
|
264
|
+
| LookAgain Report |
|
|
265
|
+
| Model: gpt-4o |
|
|
266
|
+
| LookAgain Score: 72.5/100 |
|
|
267
|
+
| MODERATE RISK |
|
|
268
|
+
+------------------------------------------+
|
|
269
|
+
|
|
270
|
+
Audit complete. LookAgain Score: 72.5/100
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### 5. View Reports
|
|
274
|
+
|
|
275
|
+
Reports are saved to `./lookagain_results/`:
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
lookagain_results/
|
|
279
|
+
├── lookagain_report.json # Machine-readable results
|
|
280
|
+
└── lookagain_report.md # Human-readable summary
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## Configuration
|
|
286
|
+
|
|
287
|
+
LookAgain supports configuration via files or environment variables.
|
|
288
|
+
|
|
289
|
+
### Configuration File
|
|
290
|
+
|
|
291
|
+
Create `.lookagain.yaml` in your project root:
|
|
292
|
+
|
|
293
|
+
```yaml
|
|
294
|
+
model:
|
|
295
|
+
provider: openai
|
|
296
|
+
model: gpt-4o
|
|
297
|
+
|
|
298
|
+
judge:
|
|
299
|
+
provider: openai
|
|
300
|
+
model: gpt-4o
|
|
301
|
+
|
|
302
|
+
output:
|
|
303
|
+
directory: ./lookagain_results
|
|
304
|
+
formats:
|
|
305
|
+
- terminal
|
|
306
|
+
- json
|
|
307
|
+
- markdown
|
|
308
|
+
|
|
309
|
+
logging:
|
|
310
|
+
level: INFO
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Environment Variables
|
|
314
|
+
|
|
315
|
+
| Variable | Description | Default |
|
|
316
|
+
|----------|-------------|---------|
|
|
317
|
+
| `LOOKAGAIN_PROVIDER` | Model provider | `openai` |
|
|
318
|
+
| `LOOKAGAIN_MODEL` | Model name | `gpt-4o` |
|
|
319
|
+
| `LOOKAGAIN_API_KEY` | API key | Provider-specific |
|
|
320
|
+
| `LOOKAGAIN_HTTP_BASE_URL` | HTTP provider base URL | -- |
|
|
321
|
+
| `LOOKAGAIN_OUTPUT_DIR` | Output directory | `./lookagain_results` |
|
|
322
|
+
| `LOOKAGAIN_LOG_LEVEL` | Logging level | `INFO` |
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## CLI Reference
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
lookagain audit [OPTIONS]
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
| Flag | Description | Default |
|
|
333
|
+
|------|-------------|---------|
|
|
334
|
+
| `--provider` | VLM provider (`openai`, `anthropic`, `gemini`, `http`) | `openai` |
|
|
335
|
+
| `--model` | Model identifier | `gpt-4o` |
|
|
336
|
+
| `--judge-provider` | Judge provider | Same as `--provider` |
|
|
337
|
+
| `--judge` | Judge model | Same as `--model` |
|
|
338
|
+
| `--base-url` | Base URL for HTTP providers | -- |
|
|
339
|
+
| `--output` | Output directory | `./lookagain_results` |
|
|
340
|
+
| `--format` | Report formats (comma-separated) | `terminal,json,markdown` |
|
|
341
|
+
| `--data-dir` | Custom test cases directory | Built-in |
|
|
342
|
+
| `--dry-run` | Estimate token usage | -- |
|
|
343
|
+
| `--api-key` | API key (overrides env var) | -- |
|
|
344
|
+
| `--config` | Config file path | `.lookagain.yaml` |
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Project Structure
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
lookagain/
|
|
352
|
+
├── src/lookagain/
|
|
353
|
+
│ ├── __init__.py
|
|
354
|
+
│ ├── cli.py # CLI entry point
|
|
355
|
+
│ ├── config.py # Configuration management
|
|
356
|
+
│ ├── test_suite.py # Audit orchestration
|
|
357
|
+
│ ├── scorer.py # LookAgain Score computation
|
|
358
|
+
│ ├── reporter.py # Report generation
|
|
359
|
+
│ ├── models/ # VLM adapters
|
|
360
|
+
│ │ ├── base.py # Abstract base class
|
|
361
|
+
│ │ ├── openai_model.py # OpenAI adapter
|
|
362
|
+
│ │ ├── anthropic_model.py # Anthropic adapter
|
|
363
|
+
│ │ ├── gemini_model.py # Google Gemini adapter
|
|
364
|
+
│ │ ├── http_model.py # OpenAI-compatible endpoints
|
|
365
|
+
│ │ └── factory.py # Model factory
|
|
366
|
+
│ ├── judge/ # LLM-as-Judge adapters
|
|
367
|
+
│ │ ├── base.py # Abstract base class
|
|
368
|
+
│ │ ├── openai_judge.py # OpenAI Judge
|
|
369
|
+
│ │ ├── prompts.py # Judge prompt templates
|
|
370
|
+
│ │ └── factory.py # Judge factory
|
|
371
|
+
│ ├── scenarios/ # Test scenarios
|
|
372
|
+
│ │ ├── base.py # Base scenario + TestResult
|
|
373
|
+
│ │ ├── missing_image.py # Missing Image test
|
|
374
|
+
│ │ ├── wrong_image.py # Wrong Image test
|
|
375
|
+
│ │ ├── corruption.py # Image Corruption test
|
|
376
|
+
│ │ └── text_bias.py # Text Bias test
|
|
377
|
+
│ └── utils/
|
|
378
|
+
│ ├── embedding.py # Text embedding similarity
|
|
379
|
+
│ ├── image_utils.py # Image corruption utilities
|
|
380
|
+
│ └── logging_config.py # Logging configuration
|
|
381
|
+
├── data/
|
|
382
|
+
│ ├── generate_images.py # Synthetic image generator
|
|
383
|
+
│ ├── images/ # Generated test images
|
|
384
|
+
│ └── test_cases/ # JSON test definitions
|
|
385
|
+
├── tests/
|
|
386
|
+
│ ├── test_smoke.py # Smoke tests
|
|
387
|
+
│ └── test_scorer_reporter.py # Scorer/reporter tests
|
|
388
|
+
├── .lookagain.yaml # Example config
|
|
389
|
+
├── pyproject.toml # Project metadata
|
|
390
|
+
└── README.md
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
## Custom Test Cases
|
|
396
|
+
|
|
397
|
+
Create custom test cases in JSON format:
|
|
398
|
+
|
|
399
|
+
```json
|
|
400
|
+
[
|
|
401
|
+
{
|
|
402
|
+
"id": "custom_001",
|
|
403
|
+
"question": "What animal is in this image?",
|
|
404
|
+
"risk_category": "Object Recognition",
|
|
405
|
+
"image_path": "images/my_test.jpg",
|
|
406
|
+
"ground_truth": "A golden retriever dog"
|
|
407
|
+
}
|
|
408
|
+
]
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Run with custom test cases:
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
lookagain audit --provider openai --model gpt-4o --data-dir ./my_test_cases
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## Development
|
|
420
|
+
|
|
421
|
+
### Setup Development Environment
|
|
422
|
+
|
|
423
|
+
```bash
|
|
424
|
+
git clone https://github.com/Fengrru/lookagain.git
|
|
425
|
+
cd lookagain
|
|
426
|
+
pip install -e ".[dev]"
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### Run Tests
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
pytest tests/ -v
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### Code Quality
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
# Linting
|
|
439
|
+
ruff check src/
|
|
440
|
+
|
|
441
|
+
# Formatting
|
|
442
|
+
ruff format src/
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
## Roadmap
|
|
448
|
+
|
|
449
|
+
- [x] Multi-provider support (OpenAI, Anthropic, Gemini, HTTP/local)
|
|
450
|
+
- [x] Built-in synthetic test images
|
|
451
|
+
- [x] Configuration file support
|
|
452
|
+
- [x] Structured logging
|
|
453
|
+
- [ ] Web dashboard and PDF compliance reports
|
|
454
|
+
- [ ] Cost optimization: local lightweight judge, rule caching
|
|
455
|
+
- [ ] Additional scenarios: adversarial images, multi-image, charts, video frames
|
|
456
|
+
- [ ] Async/parallel execution support
|
|
457
|
+
- [ ] Public leaderboard and open benchmark dataset
|
|
458
|
+
|
|
459
|
+
---
|
|
460
|
+
|
|
461
|
+
## Contributing
|
|
462
|
+
|
|
463
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
464
|
+
|
|
465
|
+
### Areas for Contribution
|
|
466
|
+
|
|
467
|
+
- New VLM provider adapters
|
|
468
|
+
- Additional test scenarios
|
|
469
|
+
- Judge implementations (Anthropic, Gemini native)
|
|
470
|
+
- Documentation improvements
|
|
471
|
+
- Bug fixes and tests
|
|
472
|
+
|
|
473
|
+
---
|
|
474
|
+
|
|
475
|
+
## Citation
|
|
476
|
+
|
|
477
|
+
If you use LookAgain in your research, please cite:
|
|
478
|
+
|
|
479
|
+
```bibtex
|
|
480
|
+
@software{lookagain2024,
|
|
481
|
+
title={LookAgain: Black-box Reliability Auditor for Vision-Language Models},
|
|
482
|
+
author={Fengrru},
|
|
483
|
+
year={2024},
|
|
484
|
+
version={0.1.0},
|
|
485
|
+
url={https://github.com/Fengrru/lookagain}
|
|
486
|
+
}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
## License
|
|
492
|
+
|
|
493
|
+
This project is licensed under the MIT License -- see [LICENSE](LICENSE) for details.
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
## Acknowledgments
|
|
498
|
+
|
|
499
|
+
- Built with inspiration from [VLMEvalKit](https://github.com/open-compass/VLMEvalKit) and [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness)
|
|
500
|
+
- Uses [OpenAI](https://openai.com/), [Anthropic](https://www.anthropic.com/), and [Google](https://ai.google.dev/) APIs for model evaluation
|