Skip to content

v1: runnable extraction, sources, Q&A, batch and web demo - #1

Merged
concerttttt merged 13 commits into
mainfrom
v1
Nov 11, 2026
Merged

concerttttt merged 13 commits into
mainfrom
v1

Conversation

@concerttttt

Copy link
Copy Markdown

Makes document-extractor runnable end to end (v1). Do not merge until reviewed.

What's in it

  • scripts/make_samples.py generates samples/: 4 invoice layouts, 2 contracts, 1 image-only scan, each with a ground-truth JSON. All names and numbers are fictional.
  • src/document_extractor/: PDF words with page and box (pdfplumber, pypdfium2); OCR for scans (Florence-2 on hf, optional vision model on api); YAML schemas to typed JSON with a {page, bbox, text} source per value; Q&A with cited passages (bge-m3, or BM25).
  • Backends via MS_BACKEND: api (OpenAI-compatible: MS_API_BASE, MS_API_KEY, MS_MODEL) and hf (transformers, default Qwen2.5-7B-Instruct, MS_HF_MODEL for 1.5B on CPU).
  • CLI: extract, ask, batch, serve. Gradio demo in app.py.
  • Tests with a mocked LLM and a GitHub Actions workflow (Python 3.11 and 3.12).
  • README: verified Quickstart, limitations, ticked Roadmap, demo GIF/MP4.

Verified on a CPU-only machine, from a fresh clone in a fresh venv

  • hf backend with Qwen2.5-1.5B-Instruct: extract, ask, batch, serve and scripts/evaluate.py on all samples.
  • api backend against a local llama-cpp-python server running Qwen2.5-1.5B-Instruct (Q4_K_M GGUF), using the README commands.
  • Not verified: the 7B default (needs a GPU) and OCR through a real vision model on the api backend (only mocked).

The demo recording replays results that the 1.5B model computed earlier on this machine; the same question gives the same answer when run live.

Modelshifts added 13 commits November 11, 2026 23:49
Seven fictional PDFs (four invoice layouts, two contracts, one image-only
scan) generated with reportlab, each with a ground-truth JSON file.
- PDF words with page and box coordinates (pdfplumber, pypdfium2)
- OCR for scanned pages: Florence-2 (hf) or a vision model (api)
- YAML schemas mapped to typed JSON, each value linked to its source
- Q&A with cited passages: bge-m3 embeddings or BM25
- Backends selected with MS_BACKEND: OpenAI-compatible API or transformers
- CLI: extract, ask, batch, serve; Gradio demo in app.py
Split passages at clause headings, ask for a one-sentence answer that ends
with a citation, re-point citations that clearly name the wrong passage,
drop citations from 'not found' answers, and mean-pool per-token vectors
from embedding endpoints that return them.
Scrollable left panel next to a fixed page view, sample picker with an
upload button, field badges placed beside their boxes, and Modelshifts
colours.
Verified Quickstart, API backend notes, schemas, samples and tests,
limitations, ticked Roadmap items and the demo GIF/MP4.
Qwen2.5-1.5B answered 'not found' to a question its top passage answered.
@concerttttt
concerttttt merged commit a390b01 into main Nov 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant