Welcome to the PDF Question Answering Pipeline! π This project provides a comprehensive solution to convert PDF documents into text, perform Optical Character Recognition (OCR), and evaluate the extracted text using various advanced models for question answering tasks. Whether you're dealing with large-scale document processing or need robust text analysis, this pipeline has got you covered! π οΈ
| Model Name | Inference Time (s) | BERTScore F1 (%) | ROUGE-L (%) | Model Size (B/M) |
|---|---|---|---|---|
| mistral/7b | 16.94 | 57.58 | 18 | 7 B |
| llama/3.2-1b | 16.26 | 53.06 | 13.7 | 1.3 B |
| llama/3.2-11b vision | 104 (per page) | 73.61 | 36.19 | 11 B |
| Layoutlmv3 | 68.026 | 33.61 | 0 | 0.125 B |
| LLAVA | 12.438 (per page) | 62.47 | 22.76 | 7 B |
| BAKLLAVA | 5.49 (per page) | 41.58 | 12.12 | 7 B |
| naver-clova-ix/donut-base-finetuned-docvqa | 326.98 | 44.36 | 18.52 | 200.42 M |
| microsoft/udop-large | 132.4660 | 65.76 | 37.21 | 741.65 M |
| twmkn9/distilbert-base-uncased-squad2 | 3.7807 | 30.15 | 0.00 | 66.36 M |
| deepset/bert-large-uncased-whole-word-masking-squad2 | 33.6416 | 35.42 | 6.25 | 334.09 M |
| deepset/roberta-base-squad2 | 10.9366 | 31.50 | 0.00 | 124.06 M |
| allenai/longformer-base-4096 | 32.2392 | 32.28 | 6.06 | 148.07 M |
Note: The scores and times are empirical and based on experiments performed on my M1 machine, please run them on your machine to get an accurate estimate on your hardware.
Clone the Repository
git clone https://github.com/yourusername/pdf-processing-pipeline.git
cd pdf-processing-pipeline
Install Dependencies
Ensure you have Python 3.x installed. Then, install the required Python libraries:
pip install -r requirements.txt
Additional Setup
Follow these steps to process your PDF documents and evaluate the extracted text for question answering:
Convert PDF to Images
python pdf2img.py
This will convert your PDF files into images and save them in the output_images directory.
Perform OCR on Images
python img2ocr.py
This step extracts text from the images and saves the output in the ocr_output directory.
Combine Extracted Texts
python combine_texts.py
Merges all text files into a single combined_output.txt for streamlined analysis.
Evaluate with Models for QA
Choose the evaluator based on your requirements:
python long_text_only_new.py
python layoutlm.py
python udop.py
python donut.py
python short_text_only_model.py
pdf2imagepytesseracttransformersevaluatenatsortjoblibtqdmPillowrequestsnumpytorchpdf-processing-pipeline/
βββ pdf2img.py
βββ img2ocr.py
βββ combine_texts.py
βββ long_text_only_new.py
βββ layoutlm.py
βββ udop.py
βββ donut.py
βββ short_text_only_model.py
βββ requirements.txt
βββ README.md
βββ LICENSE
Copyright Β© 2023 Shrey Mishra. All rights reserved.
This project is licensed under the following terms:
By using this code, you agree to these terms.
Shrey Mishra
PhD Candidate at ENS PARIS
Email: [email protected]
β¨ Happy Processing! If you have any questions or need further assistance, feel free to open an issue or reach out. We're here to help! π
Welcome to the PDF Question Answering Pipeline! π This project provides a comprehensive solution to convert PDF documents into text, perform Optical Character Recognition (OCR), and evaluate the extracted text using various advanced models for question answering tasks. Whether you're dealing with large-scale document processing or need robust text analysis, this pipeline has got you covered! π οΈ
| Model Name | Inference Time (s) | BERTScore F1 (%) | ROUGE-L (%) | Model Size (B/M) |
|---|---|---|---|---|
| mistral/7b | 16.94 | 57.58 | 18 | 7 B |
| llama/3.2-1b | 16.26 | 53.06 | 13.7 | 1.3 B |
| llama/3.2-11b vision | 104 (per page) | 73.61 | 36.19 | 11 B |
| Layoutlmv3 | 68.026 | 33.61 | 0 | 0.125 B |
| LLAVA | 12.438 (per page) | 62.47 | 22.76 | 7 B |
| BAKLLAVA | 5.49 (per page) | 41.58 | 12.12 | 7 B |
| naver-clova-ix/donut-base-finetuned-docvqa | 326.98 | 44.36 | 18.52 | 200.42 M |
| microsoft/udop-large | 132.4660 | 65.76 | 37.21 | 741.65 M |
| twmkn9/distilbert-base-uncased-squad2 | 3.7807 | 30.15 | 0.00 | 66.36 M |
| deepset/bert-large-uncased-whole-word-masking-squad2 | 33.6416 | 35.42 | 6.25 | 334.09 M |
| deepset/roberta-base-squad2 | 10.9366 | 31.50 | 0.00 | 124.06 M |
| allenai/longformer-base-4096 | 32.2392 | 32.28 | 6.06 | 148.07 M |
Note: The scores and times are empirical and based on experiments performed on my M1 machine, please run them on your machine to get an accurate estimate on your hardware.
Clone the Repository
git clone https://github.com/yourusername/pdf-processing-pipeline.git
cd pdf-processing-pipeline
Install Dependencies
Ensure you have Python 3.x installed. Then, install the required Python libraries:
pip install -r requirements.txt
Additional Setup
Follow these steps to process your PDF documents and evaluate the extracted text for question answering:
Convert PDF to Images
python pdf2img.py
This will convert your PDF files into images and save them in the output_images directory.
Perform OCR on Images
python img2ocr.py
This step extracts text from the images and saves the output in the ocr_output directory.
Combine Extracted Texts
python combine_texts.py
Merges all text files into a single combined_output.txt for streamlined analysis.
Evaluate with Models for QA
Choose the evaluator based on your requirements:
python long_text_only_new.py
python layoutlm.py
python udop.py
python donut.py
python short_text_only_model.py
pdf2imagepytesseracttransformersevaluatenatsortjoblibtqdmPillowrequestsnumpytorchpdf-processing-pipeline/
βββ pdf2img.py
βββ img2ocr.py
βββ combine_texts.py
βββ long_text_only_new.py
βββ layoutlm.py
βββ udop.py
βββ donut.py
βββ short_text_only_model.py
βββ requirements.txt
βββ README.md
βββ LICENSE
Copyright Β© 2023 Shrey Mishra. All rights reserved.
This project is licensed under the following terms:
By using this code, you agree to these terms.
Shrey Mishra
PhD Candidate at ENS PARIS
Email: [email protected]
β¨ Happy Processing! If you have any questions or need further assistance, feel free to open an issue or reach out. We're here to help! π