Compare commits
3 Commits
4f367357fc
...
6f2d664185
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f2d664185 | |||
| 7387d17a20 | |||
| 430cdf32cf |
+41
-9
@@ -23,18 +23,50 @@
|
||||
|
||||
Rationale: De-risk unknowns (Docling OCR quality, Ollama CPU inference speed) before building orchestrator.
|
||||
|
||||
### 1a. Docker Compose + Docling
|
||||
### 1a. Docker Compose + Docling (DONE)
|
||||
|
||||
- [ ] Docker Compose base (Docling service)
|
||||
- [ ] Test Docling API with sample PDFs (curl)
|
||||
- [ ] Validate OCR quality on real PDFs + generated samples
|
||||
- [x] Docker Compose base (Docling service)
|
||||
- [x] Test Docling API with sample PDFs (curl)
|
||||
- [x] Validate OCR quality on real PDFs + generated samples
|
||||
- [x] Test OCR on images (PNG) — works with `force_ocr=true`
|
||||
|
||||
### 1b. Ollama
|
||||
**Docling API Spec:**
|
||||
|
||||
- [ ] Add Ollama to Docker Compose (Qwen3-1.7B, CPU mode)
|
||||
- [ ] Test structured extraction prompt (curl)
|
||||
- [ ] Measure inference time per document
|
||||
- [ ] Validate extraction accuracy (deadline, doc type, etc.)
|
||||
- Image: `ds4sd/docling-serve:latest`
|
||||
- Port: `5001`
|
||||
- Endpoint: `POST /v1/convert/file`
|
||||
- Form params: `files=@<path>;type=application/pdf`, `to_formats=md`, `do_ocr=true`
|
||||
- Response: `{ "document": { "md_content": "..." }, "status": "success" }`
|
||||
- OCR engine: `easyocr` (default), supports CJK
|
||||
|
||||
**OCR Options:**
|
||||
|
||||
- `do_ocr=true` — enabled by default, processes bitmap content
|
||||
- `force_ocr=true` — use for images/scanned PDFs (replaces existing text with OCR)
|
||||
- `ocr_engine` — `easyocr` (default), `tesseract`, `rapidocr`, `tesserocr`, `ocrmac`
|
||||
- `ocr_lang` — language codes (engine-specific), e.g. `ch_sim` for Simplified Chinese
|
||||
|
||||
**Tested Formats:**
|
||||
|
||||
- PDF (Filing Receipt) — extracted text, tables, CJK content ✅
|
||||
- PNG (Email screenshot) — extracted subject, dates, recipient ✅ (CJK trademark garbled, may need `ocr_lang`)
|
||||
|
||||
### 1b. Ollama (DONE)
|
||||
|
||||
- [x] Add Ollama to Docker Compose (Qwen3-1.7B, CPU mode)
|
||||
- [x] Test structured extraction prompt (curl)
|
||||
- [x] Measure inference time per document (~15-30s on 4 vCPU)
|
||||
- [x] Validate extraction accuracy (deadline, doc type, etc.)
|
||||
|
||||
**Ollama API Spec:**
|
||||
|
||||
- Image: `ollama/ollama:0.9.3`
|
||||
- Port: `11434`
|
||||
- Model: `qwen3:1.7b` (~1.4 GB, auto-pulled on startup)
|
||||
- Endpoint: `POST /api/generate`
|
||||
- Body: `{"model":"qwen3:1.7b","prompt":"...","stream":false,"options":{"temperature":0}}`
|
||||
- Response: `{ "response": "<json>" }` (strip `<think>...</think>` tags in post-processing)
|
||||
- Note: Qwen3 includes reasoning by default; `/no_think` leaves empty tags, so strip instead
|
||||
|
||||
### 1c. Python Tools Service
|
||||
|
||||
|
||||
@@ -3,20 +3,34 @@ services:
|
||||
docling:
|
||||
# https://github.com/docling-project/docling-serve
|
||||
# 5001: Web UI + API
|
||||
# OCR: EasyOCR with English + Chinese Simplified + Traditional (auto-downloaded on first run)
|
||||
|
||||
image: ghcr.io/docling-project/docling-serve-cpu:v1.13.0
|
||||
container_name: jt-docling
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
DOCLING_SERVE_ENABLE_UI: "true"
|
||||
volumes:
|
||||
- docling_models:/opt/app-root/src/.cache/docling/models
|
||||
ports:
|
||||
- "5001:5001"
|
||||
entrypoint: ["/bin/sh", "-c"]
|
||||
command:
|
||||
- |
|
||||
# Download Chinese OCR models if missing (first run only)
|
||||
if [ ! -f /opt/app-root/src/.cache/docling/models/EasyOcr/zh_sim_g2.pth ] || [ ! -f /opt/app-root/src/.cache/docling/models/EasyOcr/zh_tra_g2.pth ]; then
|
||||
echo "Downloading Chinese OCR models (Simplified + Traditional)..."
|
||||
python3 -c "import easyocr; easyocr.Reader(['en','ch_sim','ch_tra'], gpu=False)"
|
||||
# Copy downloaded models to correct location
|
||||
cp -n /opt/app-root/src/.EasyOCR/model/*.pth /opt/app-root/src/.cache/docling/models/EasyOcr/ 2>/dev/null || true
|
||||
fi
|
||||
exec uvicorn docling_serve.app:app --host 0.0.0.0 --port 5001
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-sf", "http://localhost:5001/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 60s
|
||||
start_period: 120s
|
||||
|
||||
# Ollama
|
||||
ollama:
|
||||
@@ -55,5 +69,7 @@ services:
|
||||
# retries: 3
|
||||
|
||||
volumes:
|
||||
docling_models:
|
||||
name: jt-docling-models
|
||||
ollama_data:
|
||||
name: jt-ollama-data
|
||||
|
||||
Reference in New Issue
Block a user