Add LiteParse engine adapter and comprehensive benchmarking suite#3
Merged
Merged
Conversation
…ngine Add LiteParse adapter that calls the `lit` CLI via subprocess for fast local document parsing with bounding boxes and confidence scores. No Python dependencies required — only Node.js 18+ with @llamaindex/liteparse installed globally. Changes: - New engine adapter: src/docfold/engines/liteparse_engine.py - Tests: tests/engines/test_liteparse_engine.py (14 tests) - Router: added liteparse to priority maps for PDF, Office, images - CLI: registered LiteParseEngine in _build_router() - pyproject.toml: added [liteparse] optional dependency group - docs/benchmarks.md: added LiteParse to all comparison tables https://claude.ai/code/session_017D1jcELbNYGtk9QoUX6FA7
…enchmark
Fixed the JSON parser to handle the actual LiteParse output format:
- Page text at `pages[].text` (not nested in `content`)
- Text items at `pages[].textItems` with {x, y, width, height}
- Added `_extract_json()` to strip log lines from stdout
- Added test for log-prefix handling (15 tests total)
Benchmark results (4 synthetic digital PDFs):
- PyMuPDF: avg 4.5ms, CER=0.0, WER=0.0, avg 6.2 bboxes
- LiteParse: avg 382ms, CER=0.0, WER=0.0, avg 31.8 bboxes
Both engines achieve perfect text extraction on digital PDFs.
LiteParse provides ~5x more granular bounding boxes (word-level vs
block-level) but is ~85x slower due to Node.js subprocess overhead.
https://claude.ai/code/session_017D1jcELbNYGtk9QoUX6FA7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a new LiteParse engine adapter for fast local document parsing via CLI, along with a comprehensive benchmarking framework to compare document processing engines.
Key Changes
LiteParse Engine Adapter (
src/docfold/engines/liteparse_engine.py)LiteParseEngineclass that wraps the LiteParse CLI (lit parse) as a subprocessBenchmarking Suite (
benchmark.py)docs/benchmark_results.json) with per-document and aggregate statisticsTest Coverage (
tests/engines/test_liteparse_engine.py)Integration Updates
src/docfold/cli.py)src/docfold/engines/router.py)pyproject.toml(no Python deps, requires Node.js 18+)Notable Implementation Details
[x, y, x+width, y+height]{charactertime.perf_counter()https://claude.ai/code/session_017D1jcELbNYGtk9QoUX6FA7