From aef485d72a0c9124b6c6eeff668d96302be2b63c Mon Sep 17 00:00:00 2001 From: Jamie Lemon Date: Wed, 1 Oct 2025 15:12:26 +0100 Subject: [PATCH] Updates README. --- README.md | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8f4bac17..c161432a 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,28 @@ -# Using PyMuPDF in an RAG (Retrieval-Augmented Generation) Chatbot Environment +# PyMuPDF4LLM -This repository contains examples showing how PyMuPDF can be used as a data feed for RAG-based chatbots. +PyMuPDF4LLM is a specialized extension of PyMuPDF designed specifically for extracting content from PDFs in a format that's optimized for Large Language Models (LLMs). -Examples include scripts that start chatbots - either as simple CLI programs in REPL mode or browser-based GUIs. -Chatbot scripts follow this general structure: +## Key Features -1. **Extract Text**: Use PyMuPDF to extract text from one or more pages from one or more PDFs. Depending on the specific requirement this may be all text or only text contained in tables, the Table of Contents, etc. -This will generally be implemented as one or more Python functions called by any of the following events - which implement the actual chatbot functionality. -2. **Indexing the Extracted Text**: Index the extracted text for efficient retrieval. This index will act as the knowledge base for the chatbot. -3. **Query Processing**: When a user asks a question, process the query to determine the key information needed for a response. -4. **Retrieving Relevant Information**: Search your indexed knowledge base for the most relevant pieces of information related to the user's query. -5. **Generating a Response**: Use a generative model to generate a response based on the retrieved information. +1. Markdown Output -# Installation +- Converts PDFs to clean, structured Markdown format +- Preserves document hierarchy (headers, lists, tables) +- Makes PDF content easily digestible for LLMs like Claude, GPT, etc. + +2. Intelligent Structure Detection + +- Automatically identifies headers, paragraphs, tables, and images +- Maintains document layout and reading order +- Preserves semantic structure + +3. Image Handling + +- Extracts images from PDFs +- Can save images separately or encode them inline +- Useful for multimodal LLMs that can process images + +## Installation The Python package on PyPI [pymupdf4llm](https://pypi.org/project/pymupdf4llm/) (there also is an alias [pdf4llm](https://pypi.org/project/pdf4llm/)) is capable of converting PDF pages into **_text strings in Markdown format_** (GitHub compatible). This includes **standard text** as well as **table-based text** in a consistent and integrated view - a feature particularly important in RAG settings. @@ -42,27 +52,27 @@ To create small **chunks of text** - as opposed to generating one large string f Also new in version 0.0.2 is the optional **extraction of images** and vector graphics: use of parameter `write_images=True`. The will store PNG images in the document's folder, and the Markdown text will appropriately refer to them. The images are named like `"input.pdf-page_number-index.png"`. -# Documentation and API +## Documentation and API [Documentation](https://pymupdf.readthedocs.io/en/latest/pymupdf4llm/index.html) [API](https://pymupdf.readthedocs.io/en/latest/pymupdf4llm/api.html#pymupdf4llm-api) -# Document Support +## Document Support While PDF is by far the most important document format worldwide, it is worthwhile mentioning that all examples and helper scripts work in the same way and **_without change_** for [all supported file types](https://pymupdf.readthedocs.io/en/latest/how-to-open-a-file.html#supported-file-types). So for an XPS document or an eBook, simply provide the filename for instance as `"input.mobi"` and everything else will work as before. -# About PyMuPDF +## About PyMuPDF **PyMuPDF** adds **Python** bindings and abstractions to [MuPDF](https://mupdf.com/), a lightweight **PDF**, **XPS**, and **eBook** viewer, renderer, and toolkit. Both **PyMuPDF** and **MuPDF** are maintained and developed by [Artifex Software, Inc](https://artifex.com). PyMuPDF's homepage is located on [GitHub](https://github.com/pymupdf/PyMuPDF). -# Community +## Community Join us on **Discord** here: [#pymupdf](https://discord.gg/TSpYGBW4eq). -# License and Copyright +## License and Copyright **PyMuPDF** is available under [open-source AGPL](https://www.gnu.org/licenses/agpl-3.0.html) and commercial license agreements. If you determine you cannot meet the requirements of the **AGPL**, please contact [Artifex](https://artifex.com/contact/pymupdf-inquiry.php) for more information regarding a commercial license.