Skip to main content

Parse PDF documents into markdown formatted content using Vision LLMs

Project description

ExtractFlow Parse

SimplifyX - Document Processing

License: MIT

🚀 Getting Started

Prerequisites

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

The easiest way to get started is by exploring the examples folder for additional sample use cases.

Azure LLama Vision

QWEN2-VL

OpenAI

Gemini

Ollama

Models Support

ExtractFlow supports various vision language models from different providers:

OpenAI Compatible Models

  • You can use any model that is compatible with OpenAI API.
  • By passing openai_compatible=True, and base_url to the parser, the parser will use the OpenAI API to process the image.

Ollama Models

  • llama3.2-vision:11b
  • llama3.2-vision:70b
  • llava:13b
  • llava:34b

OpenAI Models

  • gpt-4o
  • gpt-4o-mini

Gemini Models

  • gemini-1.5-flash
  • gemini-2.0-flash-exp
  • gemini-1.5-pro

Installation

Install the package using pip (Recommended):

pip install extractflow_parser

Install the optional dependencies for OpenAI or Gemini:

pip install 'extractflow_parser[openai]'
pip install 'extractflow_parser[gemini]'

Setting up Ollama (Optional)

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

⌛️ Usage

Basic Example Usage

from extractflow_parser import ExtractFlowParser

# Initialize parser
parser = ExtractFlowParser(
    openai_compatible=True,
    base_url="https://api.fireworks.ai/inference/v1",
    api_key="your_api_key",
    model_name="accounts/fireworks/models/qwen2-vl-72b-instruct",
    temperature=0.2,
    top_p=0.3,
    extraction_complexity=True # 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 extractflow_parser import ExtractFlowParser, 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 = ExtractFlowParser(
    model_name="llama3.2-vision:11b",
    temperature=0.7,
    top_p=0.4,
    extraction_complexity=False,
    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 extractflow_parser import ExtractFlowParser

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

# Initialize parser with Google Gemini model
parser = ExtractFlowParser(
    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.7,
    top_p=0.4,
    extraction_complexity=True # Set to True for more detailed extraction
)

📄 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

extractflow_parser-1.0.0.tar.gz (44.5 kB view details)

Uploaded Source

Built Distribution

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

extractflow_parser-1.0.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file extractflow_parser-1.0.0.tar.gz.

File metadata

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

File hashes

Hashes for extractflow_parser-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ee9cb69409b8d2e39590b76a6263937def468894cb25eb0900ebc62e1c7e1906
MD5 5a61f7e6f687ec034df454eba2def2f5
BLAKE2b-256 79c9e8880c35a61c95a5c76a6cf478e8ef21b717b78d6fc490fcd05e6d8795cf

See more details on using hashes here.

File details

Details for the file extractflow_parser-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for extractflow_parser-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 484adb97ea019a2e05e2ec1543b6b2ba28153bffc7e6f9b25611d5c8ba55fbce
MD5 0547023fd29bc4395d3890b90e7b320e
BLAKE2b-256 3654a36389af7f37bcf7214857caab84c92be6fe93b32d42e3ca185aa443bc5f

See more details on using hashes here.

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