Skip to content

0.3.1 — image size reduction (1.1 GB → 572 MB, -48%)

Choose a tag to compare

@Rishabhmannu Rishabhmannu released this 02 Jun 08:06

Headline

M1 first-pull compressed download: 1,102 MB → 571 MB (-48.1%)
Image on disk: 4.30 GB → 2.82 GB (-34.4%)

Estimated pull time on Indian residential bandwidth: ~13 min → ~6 min.

What changed

Phase 1 — .dockerignore safety

Excluded Docker-backup-*.raw (a 65 GB sparse-file restore point from the 2026-06-02 Docker Desktop disk-full event), dist/hf-snapshot-*/, logs/, cost_logs/, publish-assets/. Without the Docker-backup exclusion, any docker build from project root would have sent 65 GB to the daemon as build context.

Phase 2 — spaCy en_core_web_lgen_core_web_md

  • Saved ~760 MB uncompressed (spaCy lg bundles word vectors that md doesn't).
  • Code fix required: Presidio's AnalyzerEngine(supported_languages=[\"en\"]) default hardcodes en_core_web_lg. Without explicit NlpEngineProvider config, it auto-downloads lg (400 MB) at first chat query and times out offline. Fixed in src/services/guardrails_service.py:142-187.
  • PII recall caveat: extended PERSON-detection test caught ~20pp recall drop on single-name references ("Buffett's letter", "Dimon warned") vs full-name references where both models match.
  • Resolution: hybrid env-var opt-in. Set USE_LARGE_SPACY_MODEL=1 and install lg in the running container for compliance / HR / legal workloads that need maximum recall:
docker exec <api-container> python -m spacy download en_core_web_lg
# restart container

Phase 3 — docling moved to optional [docling] extra

  • Removed docling + opencv_python.libs + cv2 + docling_parse + rapidocr + docling_core + docling_ibm_models from default install.
  • Dropped libxcb1 + libgl1 from both Dockerfile stages (199 MB layer gone entirely).
  • pypdf is the canonical parser anyway — docling underperforms pypdf by ~29pp on RAGAS faith + ctx_prec per the credibility-rule eval evidence.
  • src/ingestion/docling_loader.py:64-68 already handled missing-docling gracefully (returns None, chunker falls back to per-page pypdf chunking).

Users who want docling: `pip install ".[docling]"` plus host-level apt install libxcb1 libgl1.

What we explicitly did NOT do

  • Base image swap (slim → distroless/alpine) — ~30 MB compressed gain at the cost of recompiling native deps + 20-40 min build time. Bad ROI when Phases 2 + 3 already exceeded the 26% compressed target.
  • Strip dev artifacts from vendored packages — skipped to keep risk surface minimal.
  • Layer split for incremental pulls — flagged for 0.4.x if pyproject.toml continues to churn.

Verification

Check Result
docker history layer audit Site-packages layer: 2.78 GB → 2.10 GB. Runtime apt layer (libxcb1+libgl1) gone entirely.
docling family removal import docling/cv2/docling_parse/rapidocr/docling_core → ImportError as expected
pytest unit tests 307 passed, 5 pre-existing flakes (test_entity_extractor + 4 test_threads_routes — same as 0.2.x/0.3.0 baseline)
Ingestion smoke load_pdf on 2 sample PDFs → pypdf-fallback mode, content extracted (5391 + 855 chars)
Graph build 19 nodes, no ImportError
Multi-arch GHCR image Built + verified on amd64 + arm64. Verify job /v1/health passed in 1m15s.
Compressed download (arm64) 571.9 MB confirmed via docker buildx imagetools inspect --raw

Try it

pip install --upgrade financebench-rag-agent
financebench upgrade
# Watch first-pull complete in ~half the time it used to take

Engineering log

Two new credibility-rule case studies (6th + 7th in the series) documented at docs/engineering-log.md:

  1. My 375 MB Phase 2 estimate vs measured 760 MB — missed that lg bundles word vectors md doesn't. Should have read spaCy's docs not just the on-disk model size.
  2. My initial "lg=md recall=1.000" report missed the single-name PERSON gap. User trusted the "go" recommendation; extended test caught it before shipping. Lesson: when comparing models for a recall-critical use case, test BOTH phrasing patterns common in the production input distribution before declaring equivalence.

Both caught BEFORE shipping. The protocol works when followed.

Multi-arch image

ghcr.io/rishabhmannu/financebench-rag-agent-api:0.3.1 (linux/amd64 + linux/arm64). Pulled automatically by `financebench upgrade`.