PDF to Markdown conversion and quote-to-bbox resolution
Project description
groundmark
PDF to Markdown conversion and quote-to-bbox resolution.
What it does
- Convert: Send PDF pages to a vision-capable LLM (via Pydantic AI) to produce clean Markdown with
<!--page-->markers between pages. - Resolve: Given verbatim quote strings, locate them in the source PDF and return bounding box coordinates. Uses pypdfium2 for per-character bbox extraction and seq-smith for Smith-Waterman alignment.
Quick Start
import asyncio
from groundmark import DocumentIndex
from groundmark.convert import Config, ModelConfig, convert
async def main():
pdf_bytes = open("document.pdf", "rb").read()
# PDF -> Markdown (requires pydantic-ai, install with e.g. groundmark[bedrock])
model = ModelConfig(name="bedrock:au.anthropic.claude-sonnet-4-6")
result = await convert(pdf_bytes, Config(model=model))
print(result.markdown[:500])
# Resolve verbatim quotes to PDF bounding boxes
doc = DocumentIndex(pdf_bytes)
resolved = doc.resolve(["the patient presented with"])
# -> {"the patient presented with": [(page, BBox(top, left, bottom, right)), ...]}
# The DocumentIndex can be reused for multiple resolve calls against the same PDF
more = doc.resolve(["another quote from the same paper"])
if __name__ == "__main__":
asyncio.run(main())
Installation
# Resolve only (no LLM dependencies)
uv add groundmark
# With LLM provider extra(s) for conversion
uv add groundmark --extra anthropic,bedrock,google,openai
Configuration
Timeouts
The LLM call for PDF-to-Markdown conversion can take several minutes for large documents, especially with Opus on Bedrock. Timeout defaults by provider:
| Provider | Default | Environment Variable |
|---|---|---|
| Bedrock (boto3) | 300s | AWS_READ_TIMEOUT |
| Anthropic (httpx) | 600s | — (use ModelSettings(timeout=...)) |
For Bedrock with Opus, 300s may not be enough. Set a higher timeout:
export AWS_READ_TIMEOUT=600
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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 groundmark-0.5.1.tar.gz.
File metadata
- Download URL: groundmark-0.5.1.tar.gz
- Upload date:
- Size: 212.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
338ed11e8dc39a17e0bf2db6f864c73130449c44e1b465a950d1ca1d45787366
|
|
| MD5 |
7c0b04def22093f482ae20978a3c96cf
|
|
| BLAKE2b-256 |
97325d09cf14d677ce54329e033096dabefe07be18dc447346c0413fe12f3068
|
Provenance
The following attestation bundles were made for groundmark-0.5.1.tar.gz:
Publisher:
release.yaml on populationgenomics/groundmark
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
groundmark-0.5.1.tar.gz -
Subject digest:
338ed11e8dc39a17e0bf2db6f864c73130449c44e1b465a950d1ca1d45787366 - Sigstore transparency entry: 1323753223
- Sigstore integration time:
-
Permalink:
populationgenomics/groundmark@f21b7520c524ab666e5dbc617b8d62af01980421 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/populationgenomics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@f21b7520c524ab666e5dbc617b8d62af01980421 -
Trigger Event:
release
-
Statement type:
File details
Details for the file groundmark-0.5.1-py3-none-any.whl.
File metadata
- Download URL: groundmark-0.5.1-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ddb8ee769ccd6940b17ba5ea61697d48bd55628f6f2689ea0330714817b2194
|
|
| MD5 |
655e5e2093cb2349d2c6f4526d610f28
|
|
| BLAKE2b-256 |
adeb312810cfed4f16b1b054e58c65b517a2de45c0d17e72384e55aceec9ea56
|
Provenance
The following attestation bundles were made for groundmark-0.5.1-py3-none-any.whl:
Publisher:
release.yaml on populationgenomics/groundmark
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
groundmark-0.5.1-py3-none-any.whl -
Subject digest:
7ddb8ee769ccd6940b17ba5ea61697d48bd55628f6f2689ea0330714817b2194 - Sigstore transparency entry: 1323753356
- Sigstore integration time:
-
Permalink:
populationgenomics/groundmark@f21b7520c524ab666e5dbc617b8d62af01980421 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/populationgenomics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@f21b7520c524ab666e5dbc617b8d62af01980421 -
Trigger Event:
release
-
Statement type: