Skip to main content

Document parsing tool for LLM training and Rag

Project description

DocParser 📄

DocParser is a powerful tool for LLM traning and other application, for examples: RAG, which support to parse multi type file, includes:

Feature 🎉

File types supported for parsing:

  • Pdf: Use OCR to parse PDF documents and output text in markdown format. The parsing results can be used for LLM pretrain, RAG, etc.

Install

From pip:

pip install docparser

From repository:

pip install git+https://github.com/feb-co/DocParser.git

Or install it directly through the installation package:

git clone https://github.com/feb-co/DocParser.git
cd DocParser
pip install -e .

API/Functional

Pdf

From CLI

You can run the following script to get the pdf parsing results:

export LOG_LEVEL="ERROR"
export DOC_PARSER_MODEL_DIR="xxx"
export DOC_PARSER_OPENAI_URL="xxx"
export DOC_PARSER_OPENAI_KEY="xxx"
export DOC_PARSER_OPENAI_MODEL="gpt-4-0125-preview"
export DOC_PARSER_OPENAI_RETRY="3"
docparser-pdf \
    --inputs path/to/file.pdf or path/to/directory \
    --output_dir output_directory \
    --page_range '0:1' --mode 'figure latex' \
    --rendering --use_llm --overwrite_result

The following is a description of the relevant parameters:

usage: docparser-pdf [-h] --inputs INPUTS --output_dir OUTPUT_DIR [--page_range PAGE_RANGE] [--mode {plain,figure placehold,figure latex}] [--rendering] [--use_llm]

options:
  -h, --help            show this help message and exit
  --inputs INPUTS       Directory where to store PDFs, or a file path to a single PDF
  --output_dir OUTPUT_DIR
                        Directory where to store the output results (md/json/images).
  --page_range PAGE_RANGE
                        The page range to parse the PDF, the format is 'start_page:end_page', that is, [start, end). Default: full.
  --mode {plain,figure placehold,figure latex}
                        The mode for parsing the PDF, to extract only the plain text or the text plus images.
  --rendering           Is it necessary to render the recognition results of the input PDF to output the recognition range? Default: False.
  --use_llm             Do you need to use LLM to format the parsing results? If so, please specify the corresponding parameters through the environment variables: DOC_PARSER_OPENAI_URL, DOC_PARSER_OPENAI_KEY, DOC_PARSER_OPENAI_MODEL. Default: False.
  --overwrite_result    If the parsed target file already exists, should it be rewritten? Default: False.

From Python

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

docparser_feb-0.0.2.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

docparser_feb-0.0.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file docparser_feb-0.0.2.tar.gz.

File metadata

  • Download URL: docparser_feb-0.0.2.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for docparser_feb-0.0.2.tar.gz
Algorithm Hash digest
SHA256 f083c9967bf97b36c25627c10e1f16d482e0a70f5292985d2ff523b5dbb80a26
MD5 0d900a7339e80a3f4e5ed9f8c55e0816
BLAKE2b-256 2134788ffdb9b6ea0c832bc1ab46ae651a326f3a62fe924a8c425c5271b82d34

See more details on using hashes here.

File details

Details for the file docparser_feb-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for docparser_feb-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 310d416edf2d96a7862e187ba169cc21c5a9e1d5e6b4fa44e61358d6c0140919
MD5 65ea0e1cc840aa9ae0f19ceb9643f72d
BLAKE2b-256 6f37308ee84efef0706837d3fcfc26d8482721d0ff70beb7d307f8edf490f9f7

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