Skip to main content

Python toolkit for document information extraction using LMDX

Project description

LMDX-flow

LMDX-flow is a Python toolkit designed for document information extraction using LMDX. It simplifies the process of creating prompts which contain document layout information and decoding LLM responses to extract valuable information from documents.

What is LMDX: LANGUAGE MODEL-BASED DOCUMENT INFORMATION EXTRACTION AND LOCALIZATION?

LMDX is a methodology for leveraging off-the-shelf LLMs for information extraction on semi-structured documents.

Paper : https://arxiv.org/pdf/2309.10952.pdf

  • Proposes a prompt that enables LLMs to perform the document IE task on leaf and hierarchical entities with precise localization, including without any training data.
  • Proposes a layout encoding scheme that communicate spatial information to the LLM without any change to its architecture.
  • Introduces a decoding algorithm transforming the LLM responses into extracted entities and their bounding boxes on the document, while discarding all hallucination.

Key Features

  • Prompt Generation: Easily create effective prompts based on the LMDX methodology.
  • Response Decoding: Extract entity values and bounding boxes by decoding and grounding the LLM responses.

Getting Started

pip install lmdx-flow
## Load the tokenizer
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")

from lmdx_flow import Pipeline
P = Pipeline(file_path,tokenizer)
prompts = P.generate_prompt(schema)
answers = P.postprocess_all_chunks(llm_responses)

To-do

  • Add support for hierarchical entities
  • Add option to use OCR-words as segment (currently uses OCR-lines as segment)

References

Explore the potential of LMDX-flow to enhance document information extraction using LLMs with ease.

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

lmdx_flow-0.1.2.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

lmdx_flow-0.1.2-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

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