A provenance-first document pipeline for turning PDFs, EPUBs, HTML, Markdown, and text into searchable definitions, claims, procedures, and formulas.
Status: working research prototype. Parsing, structured extraction, validation, pgvector storage, citation formatting, CLI search, and a review-UI foundation are implemented. A production deployment and a public document corpus are not included.
Long documents often contain useful knowledge in forms that ordinary keyword search cannot express: a calculation with named inputs, a claim with qualifiers, or a definition tied to one passage. IFRS Documents converts those passages into typed units while retaining links to the source spans that support them.
The intended result is retrieval that can answer both:
- “Where does the document define this term?”
- “How do I calculate this, and which pages support the procedure?”
| Area | Current capability |
|---|---|
| Parsing | PDF, EPUB, HTML, Markdown, and text normalized into source spans |
| Extraction | Typed definitions, claims, functions, and formulas with confidence and span IDs |
| Validation | Schema and provenance checks before database loading |
| Storage | PostgreSQL, pgvector, and optional S3-compatible raw-document storage |
| Retrieval | Full-text and vector search with human-readable page citations |
| Review | Bun/React review-UI foundation for inspecting extracted units |
| Embeddings | One validated 384-dimension contract shared by providers and pgvector columns |
The local embedding provider remains a development placeholder. Use the OpenAI provider for real semantic embeddings.
document
→ parser
→ source spans
→ typed extractors
→ validation
→ PostgreSQL + pgvector
→ CLI search / review UI
The repository is a Bun workspace:
apps/
cli/ ingest, extract, validate, load, ask, review
review-ui/ human review foundation
packages/
core/ types, validation, citations, embedding contract
parsers/ document-to-span adapters
extractors/ prompts and typed extraction
embeddings/ provider adapters and batch validation
db/ PostgreSQL and pgvector access
infra/sql/ idempotent schema and development migrations
- Bun
- PostgreSQL with the
pgvectorextension - S3-compatible storage when retaining raw documents outside the local filesystem
- Anthropic credentials for extraction
- OpenAI credentials when using the OpenAI embedding provider
git clone https://github.com/seanwessmith/ifrs-documents.git
cd ifrs-documents
bun install
bun test
bun run build
bun run lintThe test suite is deterministic and does not make paid model requests.
Copy the example environment file and fill only the services you intend to run:
cp .env.example .envConfiguration groups include PostgreSQL, S3-compatible storage, Anthropic extraction, and the embedding provider. Do not commit .env.
Initialize or update a development database:
bun setup-db.tsThe embedding-dimension migration clears incompatible cached vectors before converting columns to vector(384). Source units remain intact and embeddings can be regenerated.
bun run ifrs --help
# Parse and register a document
bun run ifrs ingest path/to/document.pdf
# Extract and validate typed units
bun run ifrs extract <document-id>
bun run ifrs validate <document-id>
# Load validated units and embeddings
bun run ifrs load <document-id>
# Retrieve functions, formulas, claims, or definitions
bun run ifrs ask "how is net profit margin calculated?" --cite=auto
# Open the review UI
bun run ifrs review <document-id>See PIPELINE.md for the longer workflow and SPEC.md for the data model.
The schema and every provider share EMBEDDING_DIMENSIONS = 384. The loading and query paths reject vectors with a different length before sending them to PostgreSQL. OpenAI's text-embedding-3-small request uses its supported dimensions parameter to match the contract.
This removes the repository's former vector(1024) versus local 384 mismatch and makes failures explicit at the provider boundary.
- Keep every extracted unit linked to supporting source spans.
- Prefer typed, inspectable units over free-form generated summaries.
- Treat embeddings as regenerable cache data, not source-of-truth content.
- Keep extraction and retrieval providers replaceable.
- Enforce quote limits and provenance checks before loading content.
- Real end-to-end ingestion requires locally configured infrastructure and provider credentials.
- The review UI is a foundation rather than a production-ready moderation system.
- The local embedding implementation is a placeholder and must not be used for meaningful retrieval evaluation.
- Ranking, formula seeding, filters, and broader claims coverage remain active prototype work tracked in
docs/upgrade-checklist.md.