Skip to main content

llama-index readers smart_pdf_loader integration

Project description

Smart PDF Loader

pip install llama-index-readers-smart-pdf-loader

SmartPDFLoader is a super fast PDF reader that understands the layout structure of PDFs such as nested sections, nested lists, paragraphs and tables. It uses layout information to smartly chunk PDFs into optimal short contexts for LLMs.

Requirements

Install the llmsherpa library if it is not already present:

pip install llmsherpa

Usage

Here's an example usage of the SmartPDFLoader:

from llama_index.readers.smart_pdf_loader import SmartPDFLoader

llmsherpa_api_url = "https://readers.llmsherpa.com/api/document/developer/parseDocument?renderFormat=all"
pdf_url = "https://arxiv.org/pdf/1910.13461.pdf"  # also allowed is a file path e.g. /home/downloads/xyz.pdf
pdf_loader = SmartPDFLoader(llmsherpa_api_url=llmsherpa_api_url)
documents = pdf_loader.load_data(pdf_url)

Now you can use the documents with other LlamaIndex components. For example, for retrieval augmented generation, try this:

from llama_index.core import VectorStoreIndex

index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()

response = query_engine.query("list all the tasks that work with bart")
print(response)

response = query_engine.query("what is the bart performance score on squad")
print(response)

More Examples

SmartPDFLoader is based on LayoutPDFReader from llmsherpa library. See the documentation there to explore other ways to use the library for connecting data from your PDFs with LLMs.

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

Built Distribution

File details

Details for the file llama_index_readers_smart_pdf_loader-0.3.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_readers_smart_pdf_loader-0.3.0.tar.gz
Algorithm Hash digest
SHA256 428c1a5dc947c715c3669daf566674ceee33c9d65dde35609a79cfe99e4c8cec
MD5 9b37c2dbb11f3404e18c09007af6e195
BLAKE2b-256 ef561733cbdf34eabffd7827126848794de9056be4c20f867fd8aa284273f8ce

See more details on using hashes here.

File details

Details for the file llama_index_readers_smart_pdf_loader-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_readers_smart_pdf_loader-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d080df19eafcc8fde53ac201b79555d773cb6882dd9bfdfcb53c1103fe6058c4
MD5 9696a62f4dfd5b5633cccd008107679b
BLAKE2b-256 48a648c4adbc5a342b03d3830c49ee616d97133d1e0d0882e8f1b1540fd9e83c

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page