Skip to main content

Parse PDF documents into markdown formatted content using Vision LLMs

Project description

Vision Parse

License: MIT Author: Arun Brahma PyPI version

🚀 Parse PDF documents into beautifully formatted markdown content using state-of-the-art Vision Language Models - all with just a few lines of code!

🎯 Introduction

Vision Parse harnesses the power of Vision Language Models to revolutionize document processing:

  • 📝 Smart Content Extraction: Intelligently identifies and extracts text and tables with high precision
  • 🎨 Content Formatting: Preserves document hierarchy, styling, and indentation for markdown formatted content
  • 🤖 Multi-LLM Support: Supports multiple Vision LLM providers i.e. OpenAI, LLama, Gemini etc. for accuracy and speed
  • 🔄 PDF Document Support: Handle multi-page PDF documents effortlessly by converting each page into byte64 encoded images
  • 📁 Local Model Hosting: Supports local model hosting using Ollama for secure document processing and for offline use

🚀 Getting Started

Prerequisites

  • 🐍 Python >= 3.9
  • 🖥️ Ollama (if you want to use local models)
  • 🤖 API Key for OpenAI or Google Gemini (if you want to use OpenAI or Google Gemini)

Installation

Install the package using pip:

pip install vision-parse

Setting up Ollama (Optional)

See examples/ollama_setup.md on how to setup Ollama locally.

⌛️ Usage

Basic Example Usage

from vision_parse import VisionParser

# Initialize parser
parser = VisionParser(
    model_name="llama3.2-vision:11b", # For local models, you don't need to provide the api key
    temperature=0.9,
    top_p=0.4,
    extraction_complexity=False # Set to True for more detailed extraction
)

# Convert PDF to markdown
pdf_path = "path/to/your/document.pdf"
markdown_pages = parser.convert_pdf(pdf_path)

# Process results
for i, page_content in enumerate(markdown_pages):
    print(f"\n--- Page {i+1} ---\n{page_content}")

PDF Page Configuration

from vision_parse import VisionParser, PDFPageConfig

# Configure PDF processing settings
page_config = PDFPageConfig(
    dpi=400,
    color_space="RGB",
    include_annotations=True,
    preserve_transparency=False
)

# Initialize parser with custom page config
parser = VisionParser(
    model_name="llama3.2-vision:11b",
    temperature=0.9,
    top_p=0.4,
    extraction_complexity=True,
    page_config=page_config
)

# Convert PDF to markdown
pdf_path = "path/to/your/document.pdf"
markdown_pages = parser.convert_pdf(pdf_path)

OpenAI or Gemini Model Usage

from vision_parse import VisionParser

# Initialize parser with OpenAI model
parser = VisionParser(
    model_name="gpt-4o",
    api_key="your-openai-api-key", # Get the OpenAI API key from https://platform.openai.com/api-keys
    temperature=0.9,
    top_p=0.4,
    extraction_complexity=False # Set to True for more detailed extraction
)

# Initialize parser with Google Gemini model
parser = VisionParser(
    model_name="gemini-1.5-flash",
    api_key="your-gemini-api-key", # Get the Gemini API key from https://aistudio.google.com/app/apikey
    temperature=0.9,
    top_p=0.4,
    extraction_complexity=False # Set to True for more detailed extraction
)

Supported Models

This package supports the following Vision LLM models:

  • OpenAI: gpt-4o, gpt-4o-mini
  • Google Gemini: gemini-1.5-flash, gemini-2.0-flash-exp, gemini-1.5-pro
  • Meta Llama and LLava from Ollama: llava:13b, llava:34b, llama3.2-vision:11b, llama3.2-vision:70b

📄 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

vision_parse-0.1.3.tar.gz (44.1 kB view details)

Uploaded Source

Built Distribution

vision_parse-0.1.3-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file vision_parse-0.1.3.tar.gz.

File metadata

  • Download URL: vision_parse-0.1.3.tar.gz
  • Upload date:
  • Size: 44.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for vision_parse-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d2778343cde5ec2920b55d8b36984ff7c777ff0a2f534b68d4e5910d7f131906
MD5 9f4a20f6bb5abd8a74bf5ad46a7cf961
BLAKE2b-256 85967e63176bf9d38b6786d5bc107f791de35ad8ed5a9406649d4dba54729bda

See more details on using hashes here.

File details

Details for the file vision_parse-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for vision_parse-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a820c0ddbb46d30c1b9e474c3224d7127ef19d67810e2f1f012f3b35179aa016
MD5 4baa2610820031b3354a95d0c4400653
BLAKE2b-256 e4a8c8c112568500c16e470d3756a19c1f87350c4bbba3262caf8cd20dc0646a

See more details on using hashes here.

Supported by

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