|
| 1 | +# VLM Metrics: Prompt Comparison (Pruna vs InferBench) |
| 2 | + |
| 3 | +Overview of prompt differences between Pruna's VLM metrics and InferBench's implementation. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Summary Table |
| 8 | + |
| 9 | +| Metric | Pruna | InferBench | Key Differences | |
| 10 | +|--------|-------|------------|-----------------| |
| 11 | +| **Alignment Score** | Single generic question | Multi-question with dependencies | Pruna: 1 prompt; InferBench: N questions from OneIG JSON | |
| 12 | +| **VQA** | Same as Alignment (reused) | Dedicated template | Both use "Does this show X? Yes/No" | |
| 13 | +| **Text Score** | Short OCR prompt | Detailed OCR prompt | InferBench: longer, explicit format rules | |
| 14 | +| **Img Edit Score** | Simple 0–10 rating | Full judge prompts from ImgEdit repo | InferBench: 5-point multi-criteria per edit type | |
| 15 | +| **VieScore** | Two short prompts | Long SC + PQ prompts | InferBench: detailed rules, JSON output | |
| 16 | +| **QA Accuracy** | Generic "What is in this image?" | Benchmark-specific questions | Different use cases | |
| 17 | +| **VLM Base (score)** | Litellm: "Answer Yes or No" / Transformers: "Question: X Answer:" | Generation + logprobs fallback | Response format differs | |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## 1. Alignment Score |
| 22 | + |
| 23 | +### Pruna |
| 24 | +- **Question**: `Does this image show "{prompt}"? Answer Yes or No.` |
| 25 | +- **Expected answer**: `Yes` |
| 26 | +- **Scope**: Single prompt–image alignment per sample |
| 27 | +- **Source**: `metric_alignment_score.py`, `metric_vqa.py` (same logic) |
| 28 | + |
| 29 | +### InferBench |
| 30 | +- **Questions**: From OneIG JSON (e.g. `anime.json`, `human.json`, `object.json`) |
| 31 | +- **Template**: `{question}. Only answer 'Yes' or 'No'. Do not answer anything else.` |
| 32 | +- **Examples**: "Are there boys?", "Are there four boys?", "Is there a nun?", etc. |
| 33 | +- **Dependencies**: Parent–child question graph; child scores set to 0 if parent is No |
| 34 | +- **Scope**: 9–20 questions per image, dependency-aware aggregation |
| 35 | +- **Source**: `alignment_score.py`, `oneig.py` (benchmark) |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## 2. VQA (Visual Question Answering) |
| 40 | + |
| 41 | +### Pruna |
| 42 | +- Same as Alignment Score: `Does this image show "{prompt}"? Answer Yes or No.` |
| 43 | +- Used for both `alignment_score` and `vqa` metrics |
| 44 | + |
| 45 | +### InferBench |
| 46 | +- **Template**: `Does this figure show "{prompt}"? Please answer yes or no.` |
| 47 | +- **Expected answer**: `Yes` |
| 48 | +- **Difference**: "figure" vs "image"; "Please answer yes or no" vs "Answer Yes or No" |
| 49 | +- **Source**: `vqa.py` |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +## 3. Text Score (OCR) |
| 54 | + |
| 55 | +### Pruna |
| 56 | +- **Prompt**: `Extract all text from this image. If no text, say 'No text'.` |
| 57 | +- **Output use**: Binary check (no text → score 10.0, else 0.0) — *Note: Pruna text_score appears to use edit distance logic elsewhere; this prompt is for OCR extraction* |
| 58 | +- **Source**: `metric_text_score.py` |
| 59 | + |
| 60 | +### InferBench |
| 61 | +- **Prompt**: |
| 62 | + ``` |
| 63 | + Extract all text visible in this image. Include logos, stylized fonts, handwritten text, and non-standard typography. |
| 64 | + Return only the extracted text, exactly as it appears—no preamble, explanation, or markdown. |
| 65 | + Preserve words, numbers, punctuation, and spacing. If no text is recognized, reply with exactly: No text recognized |
| 66 | + ``` |
| 67 | +- **Post-processing**: Hallucination removal ("addCriterion", "No text recognized"), Levenshtein vs ground truth, word accuracy |
| 68 | +- **Source**: `text_score.py` |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +## 4. Image Edit Score |
| 73 | + |
| 74 | +### Pruna |
| 75 | +- **Question**: `Rate 0-10: Does this image show "{prompt}"? Reply with a number.` |
| 76 | +- **Input**: Single edited image + prompt |
| 77 | +- **Output**: 0–10 score, normalized to [0, 1] |
| 78 | +- **Source**: `metric_img_edit_score.py` |
| 79 | + |
| 80 | +### InferBench |
| 81 | +- **Input**: Original image + edited image + edit instruction |
| 82 | +- **Judge prompts**: Fetched from ImgEdit repo (`prompts.json`) per edit type (replace, add, remove, adjust, style, extract, background, compose) |
| 83 | +- **Format**: Long multi-criteria prompts (5-point scale): |
| 84 | + - Prompt Compliance (1–5) |
| 85 | + - Visual Naturalness / Seamlessness (1–5) |
| 86 | + - Physical & Detail Integrity (1–5) |
| 87 | +- **Output**: Average of 3 scores, parsed from `"Prompt Compliance: N\nVisual Naturalness: N\n..."` format |
| 88 | +- **Source**: `img_edit_score.py`, `img_edit.py` (benchmark), external `prompts.json` |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## 5. VieScore |
| 93 | + |
| 94 | +### Pruna |
| 95 | +- **Semantic**: `Rate 0-10: Does this image show "{prompt}"?` |
| 96 | +- **Quality**: `Rate 0-10: How natural is this image? Any artifacts?` |
| 97 | +- **Aggregation**: `sqrt(semantic * quality) / 10` |
| 98 | +- **Source**: `metric_viescore.py` |
| 99 | + |
| 100 | +### InferBench |
| 101 | +- **SC (Semantic/Compliance)**: Long prompt with rules for editing success + overediting |
| 102 | + - Two images (original + edited) |
| 103 | + - `score1` = editing success (0–10), `score2` = overediting (0–10) |
| 104 | + - Output: `[score1, score2]` |
| 105 | +- **PQ (Perceptual Quality)**: Long prompt for naturalness + artifacts |
| 106 | + - Single image |
| 107 | + - `naturalness` (0–10), `artifacts` (0–10) |
| 108 | + - Output: `[naturalness, artifacts]` |
| 109 | +- **Aggregation**: `min(SC_scores)`, `min(PQ_scores)`, `overall = sqrt(SC * PQ)` |
| 110 | +- **Context**: "You are a professional digital artist..." + JSON output format |
| 111 | +- **Source**: `viescore.py` |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +## 6. QA Accuracy |
| 116 | + |
| 117 | +### Pruna |
| 118 | +- **Question**: `What is in this image? Answer:` |
| 119 | +- **Scoring**: 1.0 if non-empty response, else 0.0 |
| 120 | +- **Use**: Generic image understanding check |
| 121 | +- **Source**: `metric_qa_accuracy.py` |
| 122 | + |
| 123 | +### InferBench |
| 124 | +- **Questions**: From GenEval metadata (e.g. "Does the image show at least one red apple?", "Does the image show exactly 3 cats?") |
| 125 | +- **Template**: `{question} Please answer yes or no.` |
| 126 | +- **Expected answers**: `Yes` for all (benchmark-specific) |
| 127 | +- **Scoring**: Accuracy over N questions, n_correct, n_incorrect |
| 128 | +- **Source**: `qa_accuracy.py`, `geneval.py` (benchmark) |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +## 7. VLM Base Layer (Score Method) |
| 133 | + |
| 134 | +### Pruna – LitellmVLM & TransformersVLM |
| 135 | +- **Prompt**: `{question} Please answer yes or no.` |
| 136 | +- **Scoring**: `1.0 if answer.lower() in response else 0.0` |
| 137 | +- **Scoring**: Same substring check |
| 138 | +- **Source**: `vlm_base.py` line 371 |
| 139 | + |
| 140 | +### InferBench – OpenAIAPIVLM |
| 141 | +- **Scoring**: Prefers logprobs (Yes/No token probabilities) when available |
| 142 | +- **Fallback**: Generation + substring check ("yes"/"no" in response) |
| 143 | +- **No prompt suffix**: Question passed as-is; metrics add their own suffix |
| 144 | +- **Source**: `api_vlm_base.py` |
| 145 | + |
| 146 | +--- |
| 147 | + |
| 148 | +## Recommendations |
| 149 | + |
| 150 | +1. **Alignment / VQA**: InferBench’s multi-question + dependency setup is more detailed; Pruna’s single-question version is simpler. For OneIG-style benchmarks, InferBench’s approach is required. |
| 151 | + |
| 152 | +2. **Text Score**: InferBench’s OCR prompt is more explicit and robust; Pruna now uses InferBench-style OCR prompt and supports ground-truth edit distance when gt contains text_content. |
| 153 | + |
| 154 | +3. **Img Edit Score**: InferBench uses full ImgEdit judge prompts; Pruna uses an improved single 0–10 rating with explicit scale instructions. For ImgEdit benchmarks, InferBench’s prompts are necessary. |
| 155 | + |
| 156 | +4. **VieScore**: InferBench’s SC+PQ prompts match the original VieScore design. Pruna’s uses improved explicit 0–10 scale prompts. |
| 157 | + |
| 158 | +5. **VLM Base**: Pruna now uses unified "Please answer yes or no." suffix for both Litellm and Transformers. |
0 commit comments