Skip to main content

PDF to Markdown conversion and quote-to-bbox resolution

Project description

groundmark

groundmark

PDF to Markdown conversion and quote-to-bbox resolution.

What it does

  1. Convert: Send PDF pages to a vision-capable LLM (via Pydantic AI) to produce clean Markdown with <!--page--> markers between pages.
  2. 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, convert

async def main():
    pdf_bytes = open("document.pdf", "rb").read()

    # PDF -> Markdown (requires pydantic-ai, install with e.g. groundmark[bedrock])
    result = await convert(pdf_bytes, Config(model="bedrock:au.anthropic.claude-sonnet-4-6"))
    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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

groundmark-0.3.3.tar.gz (188.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

groundmark-0.3.3-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file groundmark-0.3.3.tar.gz.

File metadata

  • Download URL: groundmark-0.3.3.tar.gz
  • Upload date:
  • Size: 188.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for groundmark-0.3.3.tar.gz
Algorithm Hash digest
SHA256 460c66d6aeea0b4bea622a2766a525d11c3bb3304c80fbcfcd18ad31d88711eb
MD5 194eb6a8964e6d107e46efd8d5b83da7
BLAKE2b-256 05e3e75e654548901b757a000c7c749389cac5d0c69af6c09b8553e68eb75e46

See more details on using hashes here.

Provenance

The following attestation bundles were made for groundmark-0.3.3.tar.gz:

Publisher: release.yaml on populationgenomics/groundmark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file groundmark-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: groundmark-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for groundmark-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9a682167d5732ff8c2fc8e456fe828be49fe0f3a4c6bea69346cc24d5e681d07
MD5 5cb4644a0f6d6499d063079fa2945aa4
BLAKE2b-256 e7c6dbe3f031888504fba628af650145f743fe089c11215d88c743fc3faf6512

See more details on using hashes here.

Provenance

The following attestation bundles were made for groundmark-0.3.3-py3-none-any.whl:

Publisher: release.yaml on populationgenomics/groundmark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page