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"
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file extractfold-0.1.1.tar.gz.
File metadata
- Download URL: extractfold-0.1.1.tar.gz
- Upload date:
- Size: 53.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51ebeadb667264fa5c3754a82eff5a55d164864ca6144a9839666d7dc270b0d8
|
|
| MD5 |
fea69d819ec87fa02ac83e8299fa4d32
|
|
| BLAKE2b-256 |
cfeb3aa6b1a5f815595202cbadf83c5e4316a092bacd79f2cf31c3f4254df6d5
|
Provenance
The following attestation bundles were made for extractfold-0.1.1.tar.gz:
Publisher:
publish.yml on Mihailorama/extractfold
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
extractfold-0.1.1.tar.gz -
Subject digest:
51ebeadb667264fa5c3754a82eff5a55d164864ca6144a9839666d7dc270b0d8 - Sigstore transparency entry: 2534775120
- Sigstore integration time:
-
Permalink:
Mihailorama/extractfold@68de77bb87c01aaaf761ab8722c2452b3cba54d4 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Mihailorama
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@68de77bb87c01aaaf761ab8722c2452b3cba54d4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file extractfold-0.1.1-py3-none-any.whl.
File metadata
- Download URL: extractfold-0.1.1-py3-none-any.whl
- Upload date:
- Size: 42.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e123772b4389d3cf3540e9fb3f9206941bfe47d9c125a43eb24190a7c12412a0
|
|
| MD5 |
a889777776d156d3192277f20c5cb16f
|
|
| BLAKE2b-256 |
b95e501d6550ba101055ddcd62844d7f506d1f1cee18141b26eaefa54df44603
|
Provenance
The following attestation bundles were made for extractfold-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on Mihailorama/extractfold
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
extractfold-0.1.1-py3-none-any.whl -
Subject digest:
e123772b4389d3cf3540e9fb3f9206941bfe47d9c125a43eb24190a7c12412a0 - Sigstore transparency entry: 2534775228
- Sigstore integration time:
-
Permalink:
Mihailorama/extractfold@68de77bb87c01aaaf761ab8722c2452b3cba54d4 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Mihailorama
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@68de77bb87c01aaaf761ab8722c2452b3cba54d4 -
Trigger Event:
release
-
Statement type: