visual-parser 2.0.3__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. visual_parser-2.1.0/LICENSE +201 -0
  2. visual_parser-2.1.0/PKG-INFO +231 -0
  3. visual_parser-2.1.0/README.md +187 -0
  4. {visual_parser-2.0.3 → visual_parser-2.1.0}/pyproject.toml +18 -19
  5. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/__init__.py +1 -1
  6. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/cli.py +76 -2
  7. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/cli_main.py +29 -2
  8. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/config.py +8 -3
  9. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/figure_describer.py +1 -1
  10. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/metadata_extractor.py +1 -1
  11. visual_parser-2.1.0/visual_parser/model_catalog.py +189 -0
  12. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/nougat_engine.py +51 -47
  13. visual_parser-2.1.0/visual_parser/openai_gateway.py +84 -0
  14. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/pipeline.py +109 -14
  15. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/text_extractor.py +37 -11
  16. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/vision_llm.py +49 -14
  17. visual_parser-2.1.0/visual_parser.egg-info/PKG-INFO +231 -0
  18. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser.egg-info/SOURCES.txt +3 -0
  19. visual_parser-2.1.0/visual_parser.egg-info/requires.txt +22 -0
  20. visual_parser-2.0.3/PKG-INFO +0 -195
  21. visual_parser-2.0.3/README.md +0 -152
  22. visual_parser-2.0.3/visual_parser.egg-info/PKG-INFO +0 -195
  23. visual_parser-2.0.3/visual_parser.egg-info/requires.txt +0 -22
  24. {visual_parser-2.0.3 → visual_parser-2.1.0}/setup.cfg +0 -0
  25. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/__main__.py +0 -0
  26. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/jsonl_writer.py +0 -0
  27. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/pdf_tracker.py +0 -0
  28. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser/prompts.py +0 -0
  29. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser.egg-info/dependency_links.txt +0 -0
  30. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser.egg-info/entry_points.txt +0 -0
  31. {visual_parser-2.0.3 → visual_parser-2.1.0}/visual_parser.egg-info/top_level.txt +0 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the
44
+ purposes of this License, Derivative Works shall not include works
45
+ that remain separable from, or merely link (or bind by name) to the
46
+ interfaces of, the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including the
49
+ original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Zavier N. Ndum
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,231 @@
1
+ Metadata-Version: 2.4
2
+ Name: visual-parser
3
+ Version: 2.1.0
4
+ Summary: Standalone Visual-RAG PDF Parser - text extraction and Vision-LLM figure descriptions to JSONL
5
+ Author: Zavier N. Ndum
6
+ Author-email: zavier.ndum@tamu.edu
7
+ License-Expression: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/SmartLabNuclear/RADIANT_LLM
9
+ Project-URL: Repository, https://github.com/SmartLabNuclear/RADIANT_LLM
10
+ Project-URL: Docker Hub, https://hub.docker.com/r/zev94/radiant-llm
11
+ Keywords: pdf,rag,nougat,vision-llm,ocr,document-parsing,jsonl,knowledge-base
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Text Processing :: Markup
19
+ Classifier: Intended Audience :: Science/Research
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: PyMuPDF>=1.23.0
24
+ Requires-Dist: Pillow>=10.0.0
25
+ Requires-Dist: torch>=2.1.0
26
+ Requires-Dist: transformers>=4.38.0
27
+ Requires-Dist: huggingface-hub>=0.36.0
28
+ Requires-Dist: langchain-community>=0.0.20
29
+ Requires-Dist: langchain>=0.1.0
30
+ Requires-Dist: langchain-text-splitters>=0.0.1
31
+ Requires-Dist: openai>=1.14.0
32
+ Requires-Dist: google-generativeai>=0.5.0
33
+ Requires-Dist: python-dotenv>=1.0.0
34
+ Requires-Dist: tqdm>=4.66.0
35
+ Requires-Dist: nltk>=3.8
36
+ Requires-Dist: python-Levenshtein>=0.20
37
+ Provides-Extra: ocr
38
+ Requires-Dist: pytesseract>=0.3.10; extra == "ocr"
39
+ Provides-Extra: dev
40
+ Requires-Dist: pytest; extra == "dev"
41
+ Requires-Dist: ruff; extra == "dev"
42
+ Requires-Dist: mypy; extra == "dev"
43
+ Dynamic: license-file
44
+
45
+ # visual-parser (Standalone Visual-RAG PDF Ingestion)
46
+
47
+ ![Python 3.12.10](https://img.shields.io/badge/Python-3.12.10-brightgreen.svg)
48
+ ![PyTorch](https://img.shields.io/badge/PyTorch-2.1%2B-ee4c2c.svg)
49
+ ![LangChain](https://img.shields.io/badge/LangChain-0.1%2B-1C3C3C.svg)
50
+ ![CUDA](https://img.shields.io/badge/CUDA-optional-76B900.svg)
51
+
52
+ `visual-parser` is a standalone document-ingestion tool that converts PDFs into a multi-modal JSONL knowledge base (text chunks + figure descriptions + metadata). It was originally extracted from [RADIANT-LLM](https://github.com/SmartLabNuclear/RADIANT_LLM) — born out of the need for a fast, standalone PDF-ingestion path independent of any chatbot. The intended workflow is:
53
+
54
+ 1) Run `visual-parser` on curated PDFs to generate JSONL KB files.
55
+ 2) Point any downstream RAG system at the generated KB for QA over it — RADIANT-LLM, AutoSAM, and AutoFLUKA all consume the identical JSONL/registry format, so the same generated KB works with any of them without re-parsing.
56
+
57
+ ## Outputs (JSONL KB)
58
+
59
+ By default, the pipeline writes:
60
+ - `01_chunks_kb.jsonl`: chunked text extracted from PDFs (Nougat by default).
61
+ - `02_visuals_kb.jsonl`: figure/page visual descriptions (Vision LLM).
62
+ - `03_metadata_kb.jsonl`: document metadata rows (title/author/etc.).
63
+ - `04_processed_pdfs.txt`: a tracker so re-runs only process new PDFs (unless `--rebuild`).
64
+
65
+ ## GPU support
66
+
67
+ `--text-mode nougat` (the default) auto-detects and uses a CUDA GPU when one is available (`torch.cuda.is_available()`) — no flags or code changes needed. **The catch:** a plain `pip install visual-parser` (or `pip install torch`) resolves to PyPI's default **CPU-only** torch wheel, even on a machine with a real GPU. To actually get GPU acceleration, install the matching CUDA build from PyTorch's own index instead, e.g.:
68
+
69
+ ```bash
70
+ pip install torch --index-url https://download.pytorch.org/whl/cu126
71
+ ```
72
+
73
+ (pick the CUDA tag matching your driver — see [pytorch.org/get-started](https://pytorch.org/get-started/locally/)). Installing `visual-parser` again afterward won't silently downgrade this back to CPU, since the exact version you already have satisfies its own dependency requirement. Verify with:
74
+
75
+ ```bash
76
+ python -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0) if torch.cuda.is_available() else None)"
77
+ ```
78
+
79
+ ## API keys (`.env`)
80
+
81
+ Provide at least one provider:
82
+ - `OPENAI_API_KEY` (OpenAI)
83
+ - `GEMINI_API_KEY` (Gemini)
84
+
85
+ Optional:
86
+ - `HF_TOKEN` (if you use gated Hugging Face models)
87
+ - `PORTKEY_API_KEY` + `PORTKEY_OPENAI_PROVIDER_SLUG` — routes OpenAI-family calls (vision LLM + `--list-models`) through a [Portkey](https://portkey.ai) gateway instead of OpenAI directly, exposing whatever models your Portkey account has access to. Only takes effect when `OPENAI_API_KEY` is absent/empty — direct OpenAI always wins when both are set. Set `VISUAL_PARSER_FORCE_PORTKEY=true` to force Portkey even when `OPENAI_API_KEY` is also present (e.g. set at the OS/system level, where commenting it out of `.env` alone can't disable it).
88
+
89
+ ## Run with Docker (Docker Hub)
90
+
91
+ Prebuilt images are on **[zev94/radiant-llm](https://hub.docker.com/r/zev94/radiant-llm)** under the **visual-parser** tags:
92
+
93
+ | Tag | Description |
94
+ |-----|-------------|
95
+ | `visual-parser-latest` | Always latest build (rolling) |
96
+ | `visual-parser-2.0.0` | Pinned release (Apache 2.0 release) |
97
+ | `visual-parser-1.0` | Legacy — v1.0.0, stale |
98
+
99
+ ### 1) Install Docker
100
+ - Docker Desktop (Windows/macOS) or Docker Engine (Linux)
101
+
102
+ ### 2) Pull the image
103
+ ```bash
104
+ docker pull zev94/radiant-llm:visual-parser-latest
105
+ ```
106
+
107
+ ### 3) Run (input + output on the same mounted folder)
108
+ Windows PowerShell:
109
+ ```powershell
110
+ docker run --rm --env-file .env `
111
+ -v "C:\path\to\pdfs:/data" `
112
+ zev94/radiant-llm:visual-parser-latest `
113
+ --input-dir /data --output-dir /data
114
+ ```
115
+
116
+ Linux / WSL:
117
+ ```bash
118
+ docker run --rm --env-file .env \
119
+ -v "/path/to/pdfs:/data" \
120
+ zev94/radiant-llm:visual-parser-latest \
121
+ --input-dir /data --output-dir /data
122
+ ```
123
+
124
+ ### 4) Run (separate output directory)
125
+ Windows PowerShell:
126
+ ```powershell
127
+ docker run --rm --env-file .env `
128
+ -v "C:\path\to\pdfs:/data" `
129
+ -v "C:\path\to\out:/out" `
130
+ zev94/radiant-llm:visual-parser-latest `
131
+ --input-dir /data --output-dir /out
132
+ ```
133
+
134
+ ### GPU acceleration (Docker)
135
+
136
+ Add `--gpus all` to any of the run commands above to use an NVIDIA GPU for `--text-mode nougat` (the default) instead of CPU — confirmed working out of the box with Docker Desktop's WSL2 backend, no extra host setup needed on most machines. Omit it (or run on a machine with no GPU) and it falls back to CPU automatically:
137
+
138
+ ```powershell
139
+ docker run --rm --gpus all --env-file .env `
140
+ -v "C:\path\to\pdfs:/data" `
141
+ zev94/radiant-llm:visual-parser-latest `
142
+ --input-dir /data --output-dir /data
143
+ ```
144
+
145
+ ### Offline install (legacy `.tar`)
146
+
147
+ ```powershell
148
+ docker load -i .\visual-parser_0.1.0.tar
149
+ docker images # use the tag printed by Docker
150
+ ```
151
+
152
+ ### Model overrides (optional)
153
+
154
+ Default vision model is **GPT-5.4** when using `--vision-provider gpt`. Override on the command line:
155
+
156
+ ```powershell
157
+ docker run --rm --env-file .env -v "C:\path\to\pdfs:/data" `
158
+ zev94/radiant-llm:visual-parser-latest `
159
+ --input-dir /data --output-dir /data --vision-model gpt-5.4
160
+ ```
161
+
162
+ <!-- ## Run from source (Python)
163
+
164
+ From `codebase/Visual-Parser/`:
165
+ ```powershell
166
+ python visual-parser.py --input-dir "C:\path\to\pdfs"
167
+ ``` -->
168
+
169
+ ## Common configuration flags
170
+
171
+ After pulling the image, run:
172
+
173
+ ```bash
174
+ docker run --rm zev94/radiant-llm:visual-parser-latest --help
175
+ ```
176
+
177
+ For copy-paste **Docker** examples (vision presets, text modes, workers, rebuild), see [`docker-usage-examples.md`](docker-usage-examples.md).
178
+
179
+ Paths:
180
+ - `--input-dir` / `-i` (required)
181
+ - `--output-dir` / `-o` (default: same as input)
182
+
183
+ Text extraction:
184
+ - `--text-mode nougat|lightweight` (default: `nougat`)
185
+ - `--nougat-model facebook/nougat-small`
186
+ - `--chunk-size 500`
187
+ - `--chunk-overlap 100`
188
+
189
+ Vision LLM:
190
+ - `--vision-provider gpt|gemini` (default: `gpt`)
191
+ - `--vision-model gpt-5.2` (or `gpt-4o`, `gemini-2.5-flash`, etc.)
192
+ - `--vision-detail low|high|auto`
193
+ - `--reasoning-effort none|low|medium|high|xhigh`
194
+ - `--metadata-pages 2`
195
+
196
+ Performance / misc:
197
+ - `--max-workers 4`
198
+ - `--rebuild` (reprocess everything; ignore `04_processed_pdfs.txt`)
199
+ - `--list-models` — print the live, currently-available vision models for whichever provider(s) you have a key configured for, then exit (no PDF processing). Reflects Portkey's catalog too when that's what's active.
200
+ - `--version` / `-V`
201
+ - `--log-level DEBUG|INFO|WARNING|ERROR`
202
+
203
+ ---
204
+
205
+ ## Citation
206
+
207
+ If you use RADIANT-LLM or the accompanying evaluation materials, please cite the journal article:
208
+
209
+ ```bibtex
210
+ @article{ndum2026retrieval,
211
+ title={A retrieval-augmented, domain-intelligent agentic framework for reliable decision support in safety-critical nuclear engineering},
212
+ author={Ndum, Zavier Ndum and Tao, Jian and Ford, John and Yim, Mansung and Liu, Yang},
213
+ journal={Reliability Engineering \& System Safety},
214
+ pages={113057},
215
+ year={2026},
216
+ publisher={Elsevier}
217
+ }
218
+ ```
219
+
220
+ Journal: *Reliability Engineering & System Safety* (2026), article 113057
221
+ Preprint: https://arxiv.org/abs/2604.22755
222
+
223
+ ---
224
+
225
+ ## License
226
+
227
+ Copyright 2026 Zavier N. Ndum
228
+
229
+ This project is licensed under the Apache License 2.0, the same license as its parent project, [RADIANT-LLM](https://github.com/SmartLabNuclear/RADIANT_LLM). See the [LICENSE](https://github.com/SmartLabNuclear/RADIANT_LLM/blob/main/LICENSE) file in the RADIANT_LLM repository, or the `LICENSE` file bundled with this package, for the full license text.
230
+
231
+
@@ -0,0 +1,187 @@
1
+ # visual-parser (Standalone Visual-RAG PDF Ingestion)
2
+
3
+ ![Python 3.12.10](https://img.shields.io/badge/Python-3.12.10-brightgreen.svg)
4
+ ![PyTorch](https://img.shields.io/badge/PyTorch-2.1%2B-ee4c2c.svg)
5
+ ![LangChain](https://img.shields.io/badge/LangChain-0.1%2B-1C3C3C.svg)
6
+ ![CUDA](https://img.shields.io/badge/CUDA-optional-76B900.svg)
7
+
8
+ `visual-parser` is a standalone document-ingestion tool that converts PDFs into a multi-modal JSONL knowledge base (text chunks + figure descriptions + metadata). It was originally extracted from [RADIANT-LLM](https://github.com/SmartLabNuclear/RADIANT_LLM) — born out of the need for a fast, standalone PDF-ingestion path independent of any chatbot. The intended workflow is:
9
+
10
+ 1) Run `visual-parser` on curated PDFs to generate JSONL KB files.
11
+ 2) Point any downstream RAG system at the generated KB for QA over it — RADIANT-LLM, AutoSAM, and AutoFLUKA all consume the identical JSONL/registry format, so the same generated KB works with any of them without re-parsing.
12
+
13
+ ## Outputs (JSONL KB)
14
+
15
+ By default, the pipeline writes:
16
+ - `01_chunks_kb.jsonl`: chunked text extracted from PDFs (Nougat by default).
17
+ - `02_visuals_kb.jsonl`: figure/page visual descriptions (Vision LLM).
18
+ - `03_metadata_kb.jsonl`: document metadata rows (title/author/etc.).
19
+ - `04_processed_pdfs.txt`: a tracker so re-runs only process new PDFs (unless `--rebuild`).
20
+
21
+ ## GPU support
22
+
23
+ `--text-mode nougat` (the default) auto-detects and uses a CUDA GPU when one is available (`torch.cuda.is_available()`) — no flags or code changes needed. **The catch:** a plain `pip install visual-parser` (or `pip install torch`) resolves to PyPI's default **CPU-only** torch wheel, even on a machine with a real GPU. To actually get GPU acceleration, install the matching CUDA build from PyTorch's own index instead, e.g.:
24
+
25
+ ```bash
26
+ pip install torch --index-url https://download.pytorch.org/whl/cu126
27
+ ```
28
+
29
+ (pick the CUDA tag matching your driver — see [pytorch.org/get-started](https://pytorch.org/get-started/locally/)). Installing `visual-parser` again afterward won't silently downgrade this back to CPU, since the exact version you already have satisfies its own dependency requirement. Verify with:
30
+
31
+ ```bash
32
+ python -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0) if torch.cuda.is_available() else None)"
33
+ ```
34
+
35
+ ## API keys (`.env`)
36
+
37
+ Provide at least one provider:
38
+ - `OPENAI_API_KEY` (OpenAI)
39
+ - `GEMINI_API_KEY` (Gemini)
40
+
41
+ Optional:
42
+ - `HF_TOKEN` (if you use gated Hugging Face models)
43
+ - `PORTKEY_API_KEY` + `PORTKEY_OPENAI_PROVIDER_SLUG` — routes OpenAI-family calls (vision LLM + `--list-models`) through a [Portkey](https://portkey.ai) gateway instead of OpenAI directly, exposing whatever models your Portkey account has access to. Only takes effect when `OPENAI_API_KEY` is absent/empty — direct OpenAI always wins when both are set. Set `VISUAL_PARSER_FORCE_PORTKEY=true` to force Portkey even when `OPENAI_API_KEY` is also present (e.g. set at the OS/system level, where commenting it out of `.env` alone can't disable it).
44
+
45
+ ## Run with Docker (Docker Hub)
46
+
47
+ Prebuilt images are on **[zev94/radiant-llm](https://hub.docker.com/r/zev94/radiant-llm)** under the **visual-parser** tags:
48
+
49
+ | Tag | Description |
50
+ |-----|-------------|
51
+ | `visual-parser-latest` | Always latest build (rolling) |
52
+ | `visual-parser-2.0.0` | Pinned release (Apache 2.0 release) |
53
+ | `visual-parser-1.0` | Legacy — v1.0.0, stale |
54
+
55
+ ### 1) Install Docker
56
+ - Docker Desktop (Windows/macOS) or Docker Engine (Linux)
57
+
58
+ ### 2) Pull the image
59
+ ```bash
60
+ docker pull zev94/radiant-llm:visual-parser-latest
61
+ ```
62
+
63
+ ### 3) Run (input + output on the same mounted folder)
64
+ Windows PowerShell:
65
+ ```powershell
66
+ docker run --rm --env-file .env `
67
+ -v "C:\path\to\pdfs:/data" `
68
+ zev94/radiant-llm:visual-parser-latest `
69
+ --input-dir /data --output-dir /data
70
+ ```
71
+
72
+ Linux / WSL:
73
+ ```bash
74
+ docker run --rm --env-file .env \
75
+ -v "/path/to/pdfs:/data" \
76
+ zev94/radiant-llm:visual-parser-latest \
77
+ --input-dir /data --output-dir /data
78
+ ```
79
+
80
+ ### 4) Run (separate output directory)
81
+ Windows PowerShell:
82
+ ```powershell
83
+ docker run --rm --env-file .env `
84
+ -v "C:\path\to\pdfs:/data" `
85
+ -v "C:\path\to\out:/out" `
86
+ zev94/radiant-llm:visual-parser-latest `
87
+ --input-dir /data --output-dir /out
88
+ ```
89
+
90
+ ### GPU acceleration (Docker)
91
+
92
+ Add `--gpus all` to any of the run commands above to use an NVIDIA GPU for `--text-mode nougat` (the default) instead of CPU — confirmed working out of the box with Docker Desktop's WSL2 backend, no extra host setup needed on most machines. Omit it (or run on a machine with no GPU) and it falls back to CPU automatically:
93
+
94
+ ```powershell
95
+ docker run --rm --gpus all --env-file .env `
96
+ -v "C:\path\to\pdfs:/data" `
97
+ zev94/radiant-llm:visual-parser-latest `
98
+ --input-dir /data --output-dir /data
99
+ ```
100
+
101
+ ### Offline install (legacy `.tar`)
102
+
103
+ ```powershell
104
+ docker load -i .\visual-parser_0.1.0.tar
105
+ docker images # use the tag printed by Docker
106
+ ```
107
+
108
+ ### Model overrides (optional)
109
+
110
+ Default vision model is **GPT-5.4** when using `--vision-provider gpt`. Override on the command line:
111
+
112
+ ```powershell
113
+ docker run --rm --env-file .env -v "C:\path\to\pdfs:/data" `
114
+ zev94/radiant-llm:visual-parser-latest `
115
+ --input-dir /data --output-dir /data --vision-model gpt-5.4
116
+ ```
117
+
118
+ <!-- ## Run from source (Python)
119
+
120
+ From `codebase/Visual-Parser/`:
121
+ ```powershell
122
+ python visual-parser.py --input-dir "C:\path\to\pdfs"
123
+ ``` -->
124
+
125
+ ## Common configuration flags
126
+
127
+ After pulling the image, run:
128
+
129
+ ```bash
130
+ docker run --rm zev94/radiant-llm:visual-parser-latest --help
131
+ ```
132
+
133
+ For copy-paste **Docker** examples (vision presets, text modes, workers, rebuild), see [`docker-usage-examples.md`](docker-usage-examples.md).
134
+
135
+ Paths:
136
+ - `--input-dir` / `-i` (required)
137
+ - `--output-dir` / `-o` (default: same as input)
138
+
139
+ Text extraction:
140
+ - `--text-mode nougat|lightweight` (default: `nougat`)
141
+ - `--nougat-model facebook/nougat-small`
142
+ - `--chunk-size 500`
143
+ - `--chunk-overlap 100`
144
+
145
+ Vision LLM:
146
+ - `--vision-provider gpt|gemini` (default: `gpt`)
147
+ - `--vision-model gpt-5.2` (or `gpt-4o`, `gemini-2.5-flash`, etc.)
148
+ - `--vision-detail low|high|auto`
149
+ - `--reasoning-effort none|low|medium|high|xhigh`
150
+ - `--metadata-pages 2`
151
+
152
+ Performance / misc:
153
+ - `--max-workers 4`
154
+ - `--rebuild` (reprocess everything; ignore `04_processed_pdfs.txt`)
155
+ - `--list-models` — print the live, currently-available vision models for whichever provider(s) you have a key configured for, then exit (no PDF processing). Reflects Portkey's catalog too when that's what's active.
156
+ - `--version` / `-V`
157
+ - `--log-level DEBUG|INFO|WARNING|ERROR`
158
+
159
+ ---
160
+
161
+ ## Citation
162
+
163
+ If you use RADIANT-LLM or the accompanying evaluation materials, please cite the journal article:
164
+
165
+ ```bibtex
166
+ @article{ndum2026retrieval,
167
+ title={A retrieval-augmented, domain-intelligent agentic framework for reliable decision support in safety-critical nuclear engineering},
168
+ author={Ndum, Zavier Ndum and Tao, Jian and Ford, John and Yim, Mansung and Liu, Yang},
169
+ journal={Reliability Engineering \& System Safety},
170
+ pages={113057},
171
+ year={2026},
172
+ publisher={Elsevier}
173
+ }
174
+ ```
175
+
176
+ Journal: *Reliability Engineering & System Safety* (2026), article 113057
177
+ Preprint: https://arxiv.org/abs/2604.22755
178
+
179
+ ---
180
+
181
+ ## License
182
+
183
+ Copyright 2026 Zavier N. Ndum
184
+
185
+ This project is licensed under the Apache License 2.0, the same license as its parent project, [RADIANT-LLM](https://github.com/SmartLabNuclear/RADIANT_LLM). See the [LICENSE](https://github.com/SmartLabNuclear/RADIANT_LLM/blob/main/LICENSE) file in the RADIANT_LLM repository, or the `LICENSE` file bundled with this package, for the full license text.
186
+
187
+