GitHub - QuivrHQ/MegaParse: File Parser optimised for LLM Ingestion with no loss π§ Parse PDFs, Docx, PPTx in a format that is ideal for LLMs.
Extracto
File Parser optimised for LLM Ingestion with no loss π§ Parse PDFs, Docx, PPTx in a format that is ideal for LLMs. - GitHub - QuivrHQ/MegaParse: File Parser optimised for LLM Ingestion with no loss...
Contenido
MegaParse - Your Parser for every type of documents
MegaParse is a powerful and versatile parser that can handle various types of documents with ease. Whether you're dealing with text, PDFs, Powerpoint presentations, Word documents MegaParse has got you covered. Focus on having no information loss during parsing.
Key Features π―
- Versatile Parser: MegaParse is a powerful and versatile parser that can handle various types of documents with ease.
- No Information Loss: Focus on having no information loss during parsing.
- Fast and Efficient: Designed with speed and efficiency at its core.
- Wide File Compatibility: Supports Text, PDF, Powerpoint presentations, Excel, CSV, Word documents.
- Open Source: Freedom is beautiful, and so is MegaParse. Open source and free to use.
Support
- Files: β PDF β Powerpoint β Word
- Content: β Tables β TOC β Headers β Footers β Images
Example
megaparse.mp4
Installation
Usage
-
Add your OpenAI or Anthropic API key to the .env file
-
Install poppler on your computer (images and PDFs)
-
Install tesseract on your computer (images and PDFs)
-
If you have a mac, you also need to install libmagic
brew install libmagic
from megaparse import MegaParse from langchain_openai import ChatOpenAI from megaparse.parser.unstructured_parser import UnstructuredParser parser = UnstructuredParser() megaparse = MegaParse(parser) response = megaparse.load("./test.pdf") print(response) megaparse.save("./test.md")
Use MegaParse Vision
- Change the parser to MegaParseVision
from megaparse import MegaParse from langchain_openai import ChatOpenAI from megaparse.parser.megaparse_vision import MegaParseVision model = ChatOpenAI(model="gpt-4o", api_key=os.getenv("OPENAI_API_KEY")) # type: ignore parser = MegaParseVision(model=model) megaparse = MegaParse(parser) response = megaparse.load("./test.pdf") print(response) megaparse.save("./test.md")
Note: The model supported by MegaParse Vision are the multimodal ones such as claude 3.5, claude 4, gpt-4o and gpt-4.
(Optional) Use LlamaParse for Improved Results
-
Create an account on Llama Cloud and get your API key.
-
Change the parser to LlamaParser
from megaparse import MegaParse from langchain_openai import ChatOpenAI from megaparse.parser.llama_parser import LlamaParser parser = LlamaParser(api_key = os.getenv("LLAMA_CLOUD_API_KEY")) megaparse = MegaParse(parser) response = megaparse.load("./test.pdf") print(response) megaparse.save("./test.md") #saves the last processed doc in md format
Use as an API
There is a MakeFile for you, simply use :
make dev
at the root of the project and you are good to go.
See localhost:8000/docs for more info on the different endpoints !
BenchMark
| Parser | similarity_ratio |
|---|---|
| megaparse_vision | 0.87 |
| unstructured_with_check_table | 0.77 |
| unstructured | 0.59 |
| llama_parser | 0.33 |
Higher the better
Note: Want to evaluate and compare your Megaparse module with ours ? Please add your config in evaluations/script.py and then run python evaluations/script.py. If it is better, do a PR, I mean, let's go higher together .
In Construction π§
- Improve table checker
- Create Checkers to add modular postprocessing βοΈ
- Add Structured output, let's get computer talking π€
Star History
Fuente: GitHub
