|
| 1 | +# OCR API Comparison Test |
| 2 | + |
| 3 | +**Date:** 2025-12-22 |
| 4 | +**Document:** N3290x_Design_Guide_A1.pdf, Pages 889-890 |
| 5 | +**Purpose:** Compare Vision API vs OCR API for technical diagram analysis |
| 6 | + |
| 7 | +## Test Case: Power-on Sequence Timing Diagram |
| 8 | + |
| 9 | +**Location:** Page 890, Image 1 (918x482px) |
| 10 | +**Content:** Technical timing diagram with voltage signals, thresholds, and timing parameters |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## Method 1: Claude Vision (Native) |
| 15 | + |
| 16 | +**Process:** pdf-reader-mcp → Image extraction → Claude Sonnet 4.5 Vision |
| 17 | + |
| 18 | +**Result:** |
| 19 | + |
| 20 | +### Analysis: |
| 21 | +- **Identified as:** Power-on Sequence Timing-Diagramm |
| 22 | +- **Signals detected:** |
| 23 | + 1. VDD33 (blau) - 3.3V IO Power |
| 24 | + 2. 1.8V Core Power (türkis) |
| 25 | + 3. RESET (rot gestrichelt) |
| 26 | + 4. Internal RESET (magenta gestrichelt) |
| 27 | + |
| 28 | +- **Key parameters extracted:** |
| 29 | + - Threshold: 1.62V |
| 30 | + - Threshold: VDD33/2 |
| 31 | + - Timing: "More than 4T where T is XTAL cycle" |
| 32 | + - Duration: 75ms |
| 33 | + - Label: "Valid power on setting value" |
| 34 | + |
| 35 | +- **Axes:** |
| 36 | + - Y-axis: Voltage (V) |
| 37 | + - X-axis: Time (mS) |
| 38 | + |
| 39 | +**Quality:** ✅ Accurate, comprehensive technical understanding |
| 40 | + |
| 41 | +**Cost:** ~$0.01-0.02 per image (Claude API pricing) |
| 42 | + |
| 43 | +**Cache:** ❌ No persistent cache (not part of pdf-reader-mcp OCR cache) |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## Method 2: Mistral Vision API (via wrapper) |
| 48 | + |
| 49 | +**Process:** pdf-reader-mcp → Image extraction → Mistral Vision wrapper → mistral-large-2512 |
| 50 | + |
| 51 | +**Current Status:** ✅ Wrapper built and tested |
| 52 | +**API Used:** `client.chat.complete()` with vision |
| 53 | +**Model:** mistral-large-2512 |
| 54 | + |
| 55 | +**Expected Result:** Similar to Claude Vision |
| 56 | +- Semantic understanding |
| 57 | +- Identifies diagram type |
| 58 | +- General description of signals |
| 59 | + |
| 60 | +**Quality:** Expected ✅ Good for classification |
| 61 | + |
| 62 | +**Cost:** ~$0.002-0.003 per image (Mistral Vision pricing) |
| 63 | + |
| 64 | +**Cache:** ✅ Persistent disk cache (`N3290x_Design_Guide_A1_ocr.json`) |
| 65 | + |
| 66 | +**Note:** This is **Vision API**, not **OCR API** - good for "what is this?" not "extract all labels" |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## Method 3: Mistral OCR API (NOT YET IMPLEMENTED) |
| 71 | + |
| 72 | +**Process:** pdf-reader-mcp → Image/PDF → Mistral OCR wrapper → mistral-ocr-2512 |
| 73 | + |
| 74 | +**Current Status:** ❌ Not implemented (Vision wrapper built instead) |
| 75 | + |
| 76 | +**API Needed:** `client.ocr.process()` |
| 77 | +**Model:** `mistral-ocr-2512` (OCR 3) |
| 78 | +**Endpoint:** `/v1/ocr` |
| 79 | + |
| 80 | +**Expected Features:** |
| 81 | +- Structured output: `.markdown`, `.tables[]`, `.images[]` |
| 82 | +- Precise text extraction from technical diagrams |
| 83 | +- Table detection with HTML/markdown output |
| 84 | +- Header/footer extraction |
| 85 | + |
| 86 | +**Expected Result for our diagram:** |
| 87 | +```json |
| 88 | +{ |
| 89 | + "markdown": "VDD33\n1.8V Core Power\nRESET\nInternal RESET\n...", |
| 90 | + "labels": [ |
| 91 | + "Voltage (V)", |
| 92 | + "Time (mS)", |
| 93 | + "1.62V", |
| 94 | + "VDD33/2", |
| 95 | + "More than 4T where T is XTAL cycle", |
| 96 | + "75ms", |
| 97 | + "Valid power on setting value" |
| 98 | + ] |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +**Quality:** Expected ✅✅ Best for precise data extraction |
| 103 | + |
| 104 | +**Cost:** $2 per 1,000 pages = $0.002 per page ($1 with Batch API) |
| 105 | + |
| 106 | +**Cache:** ✅ Persistent disk cache (same as Vision wrapper) |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## Comparison Summary |
| 111 | + |
| 112 | +| Method | API Type | Quality | Cost/Image | Cache | Best For | |
| 113 | +|--------|----------|---------|------------|-------|----------| |
| 114 | +| **Claude Vision** | Vision | ✅ Excellent | ~$0.01-0.02 | ❌ No | Semantic understanding, complex analysis | |
| 115 | +| **Mistral Vision** | Vision | ✅ Good | ~$0.002-0.003 | ✅ Yes | Quick classification, "what is this?" | |
| 116 | +| **Mistral OCR** | OCR | ✅✅ Best | ~$0.002 | ✅ Yes | **Precise data extraction, technical diagrams** | |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Recommended Workflow: Two-Tier Approach |
| 121 | + |
| 122 | +### Tier 1: Vision Classification (Quick Triage) |
| 123 | +**Tool:** Mistral Vision wrapper (existing) |
| 124 | +- "This is a timing diagram with 4 signals" |
| 125 | +- "Complex table with 12 rows" |
| 126 | +- **Cost:** Low (~$0.003) |
| 127 | +- **Speed:** Fast |
| 128 | +- **Decision:** "Interesting? → Proceed to OCR" |
| 129 | + |
| 130 | +### Tier 2: OCR Deep Analysis (On Demand) |
| 131 | +**Tool:** Mistral OCR wrapper (to be built) |
| 132 | +- "VDD33: 3.3V, rises from 0V at t=0ms" |
| 133 | +- "Threshold: 1.62V (VDD33/2)" |
| 134 | +- "Timing constraint: >4T where T=XTAL cycle" |
| 135 | +- "Duration: 75ms until valid power-on" |
| 136 | +- **Cost:** Low (~$0.002) |
| 137 | +- **Speed:** Moderate |
| 138 | +- **Trigger:** User requests details |
| 139 | + |
| 140 | +### Benefits: |
| 141 | +- 💰 Cost-effective: Vision for triage, OCR only when needed |
| 142 | +- ⚡ Fast: Quick overview without deep analysis |
| 143 | +- 🎯 Flexible: User controls analysis depth |
| 144 | +- 💾 Cached: Both results persist in .json files |
| 145 | + |
| 146 | +--- |
| 147 | + |
| 148 | +## Action Items |
| 149 | + |
| 150 | +- [x] Build Mistral Vision wrapper (completed) |
| 151 | +- [ ] Build Mistral OCR wrapper (`client.ocr.process()`) |
| 152 | +- [ ] Implement two-tier workflow |
| 153 | +- [ ] Add Vision classification as optional step in pdf-reader-mcp |
| 154 | +- [ ] Document both approaches in guide |
| 155 | + |
| 156 | +--- |
| 157 | + |
| 158 | +## Technical Notes |
| 159 | + |
| 160 | +### Current Mistral Vision Wrapper |
| 161 | +- ✅ Working: POST /v1/ocr endpoint |
| 162 | +- ✅ Uses: `client.chat.complete()` with vision |
| 163 | +- ✅ Accepts: Base64 images, data URIs |
| 164 | +- ✅ Returns: `{ text, language }` |
| 165 | +- ⚠️ Limitation: Vision API, not OCR API - good for understanding, not extraction |
| 166 | + |
| 167 | +### Needed: Mistral OCR Wrapper |
| 168 | +- ❌ Not built yet |
| 169 | +- Should use: `client.ocr.process()` |
| 170 | +- Should accept: PDFs, base64 images |
| 171 | +- Should return: Structured data (markdown, tables, images) |
| 172 | +- Features: table_format, extract_header/footer, include_image_base64 |
| 173 | + |
| 174 | +### Why Both? |
| 175 | +- **Vision:** Semantic understanding ("This is a Power-on sequence diagram") |
| 176 | +- **OCR:** Data extraction ("VDD33=3.3V, t=75ms, threshold=1.62V") |
| 177 | +- **Together:** Complete analysis pipeline |
| 178 | + |
| 179 | +--- |
| 180 | + |
| 181 | +**Conclusion:** For technical diagrams like our timing diagram, the ideal approach is: |
| 182 | +1. Quick Vision classification to understand context |
| 183 | +2. Deep OCR analysis to extract precise values |
| 184 | +3. Both cached for future reference |
0 commit comments