extractfold
extractfold is the structured-data sibling of docfold.
docfold: document -> representation, such as Markdown, HTML, text, or layout.extractfold: document + JSON Schema -> schema-conformant Pythondict.
The core package has no required third-party dependencies. Engines that need model weights, cloud SDKs, or provider SDKs live behind optional extras and import those dependencies lazily.
Install
pip install extractfold
pip install "extractfold[provider_router]"
pip install "extractfold[llm_structured]"
pip install "extractfold[all]"
Quick Start
import asyncio
from extractfold.engines import LLMStructuredEngine
schema = {
"type": "object",
"required": ["invoice_id", "total"],
"properties": {
"invoice_id": {"type": "string"},
"vendor": {"type": "string"},
"total": {"type": "number"},
},
}
async def main() -> None:
result = await LLMStructuredEngine().extract("invoice.pdf", schema)
print(result.data)
asyncio.run(main())
CLI
extractfold extract invoice.pdf --schema invoice --engine llm_structured
extractfold extract invoice.pdf --schema schema.json --out result.json
extractfold compare invoice.pdf --schema schema.json --engines llm_structured,lift
extractfold list-engines
extractfold benchmark ./dataset --engines llm_structured,lift --out results.json
Engine Comparison
| Engine | Type | License | Schema | Nested | Confidence | Provenance | Local/Remote | Speed | Cost |
|---|---|---|---|---|---|---|---|---|---|
lift |
Datalab Lift adapter | SaaS | Native | Yes | Yes | Yes | Remote | Fast | Paid API |
nuextract |
Open model | Model license | Prompt JSON | Yes | No | No | Local | Medium | Hardware |
provider_router |
Injected model gateway | App-defined | Prompt JSON | Yes | No | No | Remote | App-defined | App-defined |
llm_structured |
LLM structured outputs | Provider terms | Tool/JSON mode | Yes | No | No | Remote | Medium | Paid tokens |
instructor |
Pydantic/JSON extraction | MIT library + provider terms | Pydantic/JSON Schema | Yes | No | No | Remote by default | Medium | Paid tokens |
fenic |
typedef-ai fenic semantic.extract |
Apache-2.0 library + provider terms | Pydantic (converted from JSON Schema) | Yes | No | No | Remote by default | Medium | Paid tokens |
llamaextract |
LlamaCloud Extract | SaaS | Native | Yes | No | No | Remote | Fast | Paid API |
azure_docint |
Azure Document Intelligence | SaaS | Query fields | Limited | Yes | Yes | Remote | Fast | Paid API |
google_docai |
Google Document AI | SaaS | Custom extractor/entities | Yes | Yes | Yes | Remote | Fast | Paid API |
textract |
AWS Textract | SaaS | QUERIES/FORMS | Limited | Yes | Yes | Remote | Fast | Paid API |
docfold_llm |
Composite | Mixed | LLM structured | Yes | Depends on LLM | Depends on LLM | Remote by default | Medium | Parse + token cost |
How To Choose
| Need | Use |
|---|---|
| Existing model gateway, retries, and telemetry | provider_router |
| Best practical default for arbitrary schemas | llm_structured |
| First-party Datalab Lift workflow | lift |
| Local/open-model extraction | nuextract |
Existing instructor stack |
instructor |
| Existing fenic dataframe pipelines | fenic |
| Managed extraction SaaS | llamaextract |
| Enterprise cloud OCR/forms/query fields | azure_docint, google_docai, or textract |
| Clean Markdown/text before extraction | docfold_llm |
Engine Examples
from extractfold.engines import (
AzureDocIntEngine,
DocfoldLLMEngine,
FenicEngine,
GoogleDocAIEngine,
InstructorEngine,
LiftEngine,
LLMStructuredEngine,
LlamaExtractEngine,
NuExtractEngine,
ProviderRouterEngine,
TextractEngine,
)
async def provider_call(**kwargs):
# Call an application-owned gateway and return JSON-compatible data.
return {"invoice_id": "INV-001", "total": 125.5}
result = await ProviderRouterEngine(provider_call=provider_call).extract("invoice.txt", "invoice")
result = await LiftEngine().extract("invoice.pdf", "invoice")
result = await NuExtractEngine(backend="hf").extract("invoice.txt", "invoice")
result = await LLMStructuredEngine(provider="anthropic").extract("invoice.pdf", "invoice")
result = await LLMStructuredEngine(provider="openai").extract("invoice.pdf", "invoice")
result = await LLMStructuredEngine(provider="gemini").extract("invoice.pdf", "invoice")
result = await InstructorEngine().extract("invoice.pdf", "invoice")
result = await FenicEngine().extract("invoice.txt", "invoice")
result = await LlamaExtractEngine().extract("invoice.pdf", "invoice")
result = await AzureDocIntEngine().extract("invoice.pdf", "invoice")
result = await GoogleDocAIEngine().extract("invoice.pdf", "invoice")
result = await TextractEngine().extract("invoice.pdf", "invoice")
result = await DocfoldLLMEngine().extract("invoice.pdf", "invoice")
Evaluation
extractfold.evaluation scores prediction folders shaped like this:
dataset/
gold/invoice.json
predictions/llm_structured/invoice.json
predictions/lift/invoice.json
Metrics include field accuracy, schema compliance, precision/recall/F1, hallucination rate, type correctness, normalized value matching, and nested array alignment.
Development
pip install -e ".[dev]"
ruff check src/ tests/
mypy src/
pytest tests/ -m "not integration"
Metadata
Release files for extractfold 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| extractfold-0.1.1.tar.gz | 53.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| extractfold-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 95.8 kB
Release files / extractfold-0.1.1.tar.gz
| Download URL | extractfold-0.1.1.tar.gz |
|---|---|
| Size | 53.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51ebeadb667264fa5c3754a82eff5a55d164864ca6144a9839666d7dc270b0d8
|
|
BLAKE2b-256 checksum How to use checksums |
cfeb3aa6b1a5f815595202cbadf83c5e4316a092bacd79f2cf31c3f4254df6d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.
Transparency logRelease files / extractfold-0.1.1-py3-none-any.whl
| Download URL | extractfold-0.1.1-py3-none-any.whl |
|---|---|
| Size | 42.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e123772b4389d3cf3540e9fb3f9206941bfe47d9c125a43eb24190a7c12412a0
|
|
BLAKE2b-256 checksum How to use checksums |
b95e501d6550ba101055ddcd62844d7f506d1f1cee18141b26eaefa54df44603
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.
Transparency logSecurity for extractfold 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for extractfold-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.