visual-parser 2.0.4__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.
- visual_parser-2.1.0/LICENSE +201 -0
- {visual_parser-2.0.4 → visual_parser-2.1.0}/PKG-INFO +51 -20
- {visual_parser-2.0.4 → visual_parser-2.1.0}/README.md +34 -4
- {visual_parser-2.0.4 → visual_parser-2.1.0}/pyproject.toml +18 -19
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/__init__.py +1 -1
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/cli.py +76 -2
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/cli_main.py +29 -2
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/config.py +8 -3
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/figure_describer.py +1 -1
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/metadata_extractor.py +1 -1
- visual_parser-2.1.0/visual_parser/model_catalog.py +189 -0
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/nougat_engine.py +51 -47
- visual_parser-2.1.0/visual_parser/openai_gateway.py +84 -0
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/pipeline.py +109 -14
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/text_extractor.py +37 -11
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/vision_llm.py +49 -14
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser.egg-info/PKG-INFO +51 -20
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser.egg-info/SOURCES.txt +3 -0
- visual_parser-2.1.0/visual_parser.egg-info/requires.txt +22 -0
- visual_parser-2.0.4/visual_parser.egg-info/requires.txt +0 -22
- {visual_parser-2.0.4 → visual_parser-2.1.0}/setup.cfg +0 -0
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/__main__.py +0 -0
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/jsonl_writer.py +0 -0
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/pdf_tracker.py +0 -0
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser/prompts.py +0 -0
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser.egg-info/dependency_links.txt +0 -0
- {visual_parser-2.0.4 → visual_parser-2.1.0}/visual_parser.egg-info/entry_points.txt +0 -0
- {visual_parser-2.0.4 → 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.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: visual-parser
|
|
3
|
-
Version: 2.0
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Standalone Visual-RAG PDF Parser - text extraction and Vision-LLM figure descriptions to JSONL
|
|
5
5
|
Author: Zavier N. Ndum
|
|
6
6
|
Author-email: zavier.ndum@tamu.edu
|
|
7
|
-
License: Apache-2.0
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
8
|
Project-URL: Homepage, https://github.com/SmartLabNuclear/RADIANT_LLM
|
|
9
9
|
Project-URL: Repository, https://github.com/SmartLabNuclear/RADIANT_LLM
|
|
10
10
|
Project-URL: Docker Hub, https://hub.docker.com/r/zev94/radiant-llm
|
|
@@ -13,43 +13,46 @@ Classifier: Programming Language :: Python :: 3
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
16
|
Classifier: Operating System :: OS Independent
|
|
18
17
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
18
|
Classifier: Topic :: Text Processing :: Markup
|
|
20
19
|
Classifier: Intended Audience :: Science/Research
|
|
21
20
|
Requires-Python: >=3.10
|
|
22
21
|
Description-Content-Type: text/markdown
|
|
23
|
-
|
|
24
|
-
Requires-Dist:
|
|
25
|
-
Requires-Dist:
|
|
26
|
-
Requires-Dist:
|
|
27
|
-
Requires-Dist:
|
|
28
|
-
Requires-Dist:
|
|
29
|
-
Requires-Dist: langchain
|
|
30
|
-
Requires-Dist: langchain
|
|
31
|
-
Requires-Dist:
|
|
32
|
-
Requires-Dist:
|
|
33
|
-
Requires-Dist:
|
|
34
|
-
Requires-Dist:
|
|
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
35
|
Requires-Dist: nltk>=3.8
|
|
36
36
|
Requires-Dist: python-Levenshtein>=0.20
|
|
37
37
|
Provides-Extra: ocr
|
|
38
|
-
Requires-Dist: pytesseract
|
|
38
|
+
Requires-Dist: pytesseract>=0.3.10; extra == "ocr"
|
|
39
39
|
Provides-Extra: dev
|
|
40
40
|
Requires-Dist: pytest; extra == "dev"
|
|
41
41
|
Requires-Dist: ruff; extra == "dev"
|
|
42
42
|
Requires-Dist: mypy; extra == "dev"
|
|
43
|
+
Dynamic: license-file
|
|
43
44
|
|
|
44
45
|
# visual-parser (Standalone Visual-RAG PDF Ingestion)
|
|
45
46
|
|
|
46
47
|

|
|
47
|
-
|
|
48
|
+

|
|
49
|
+

|
|
50
|
+

|
|
48
51
|
|
|
49
|
-
`visual-parser` is a standalone document-ingestion tool that converts PDFs into a multi-modal JSONL knowledge base (text chunks + figure descriptions + metadata). The intended workflow is:
|
|
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:
|
|
50
53
|
|
|
51
54
|
1) Run `visual-parser` on curated PDFs to generate JSONL KB files.
|
|
52
|
-
2)
|
|
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.
|
|
53
56
|
|
|
54
57
|
## Outputs (JSONL KB)
|
|
55
58
|
|
|
@@ -59,6 +62,20 @@ By default, the pipeline writes:
|
|
|
59
62
|
- `03_metadata_kb.jsonl`: document metadata rows (title/author/etc.).
|
|
60
63
|
- `04_processed_pdfs.txt`: a tracker so re-runs only process new PDFs (unless `--rebuild`).
|
|
61
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
|
+
|
|
62
79
|
## API keys (`.env`)
|
|
63
80
|
|
|
64
81
|
Provide at least one provider:
|
|
@@ -67,6 +84,7 @@ Provide at least one provider:
|
|
|
67
84
|
|
|
68
85
|
Optional:
|
|
69
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).
|
|
70
88
|
|
|
71
89
|
## Run with Docker (Docker Hub)
|
|
72
90
|
|
|
@@ -113,6 +131,17 @@ docker run --rm --env-file .env `
|
|
|
113
131
|
--input-dir /data --output-dir /out
|
|
114
132
|
```
|
|
115
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
|
+
|
|
116
145
|
### Offline install (legacy `.tar`)
|
|
117
146
|
|
|
118
147
|
```powershell
|
|
@@ -167,6 +196,8 @@ Vision LLM:
|
|
|
167
196
|
Performance / misc:
|
|
168
197
|
- `--max-workers 4`
|
|
169
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`
|
|
170
201
|
- `--log-level DEBUG|INFO|WARNING|ERROR`
|
|
171
202
|
|
|
172
203
|
---
|
|
@@ -195,6 +226,6 @@ Preprint: https://arxiv.org/abs/2604.22755
|
|
|
195
226
|
|
|
196
227
|
Copyright 2026 Zavier N. Ndum
|
|
197
228
|
|
|
198
|
-
This project is licensed under the Apache License 2.0. See the [LICENSE](https://github.com/SmartLabNuclear/RADIANT_LLM/blob/main/LICENSE) file in the RADIANT_LLM repository for the full license text.
|
|
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.
|
|
199
230
|
|
|
200
231
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# visual-parser (Standalone Visual-RAG PDF Ingestion)
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
5
7
|
|
|
6
|
-
`visual-parser` is a standalone document-ingestion tool that converts PDFs into a multi-modal JSONL knowledge base (text chunks + figure descriptions + metadata). The intended workflow is:
|
|
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:
|
|
7
9
|
|
|
8
10
|
1) Run `visual-parser` on curated PDFs to generate JSONL KB files.
|
|
9
|
-
2)
|
|
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.
|
|
10
12
|
|
|
11
13
|
## Outputs (JSONL KB)
|
|
12
14
|
|
|
@@ -16,6 +18,20 @@ By default, the pipeline writes:
|
|
|
16
18
|
- `03_metadata_kb.jsonl`: document metadata rows (title/author/etc.).
|
|
17
19
|
- `04_processed_pdfs.txt`: a tracker so re-runs only process new PDFs (unless `--rebuild`).
|
|
18
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
|
+
|
|
19
35
|
## API keys (`.env`)
|
|
20
36
|
|
|
21
37
|
Provide at least one provider:
|
|
@@ -24,6 +40,7 @@ Provide at least one provider:
|
|
|
24
40
|
|
|
25
41
|
Optional:
|
|
26
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).
|
|
27
44
|
|
|
28
45
|
## Run with Docker (Docker Hub)
|
|
29
46
|
|
|
@@ -70,6 +87,17 @@ docker run --rm --env-file .env `
|
|
|
70
87
|
--input-dir /data --output-dir /out
|
|
71
88
|
```
|
|
72
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
|
+
|
|
73
101
|
### Offline install (legacy `.tar`)
|
|
74
102
|
|
|
75
103
|
```powershell
|
|
@@ -124,6 +152,8 @@ Vision LLM:
|
|
|
124
152
|
Performance / misc:
|
|
125
153
|
- `--max-workers 4`
|
|
126
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`
|
|
127
157
|
- `--log-level DEBUG|INFO|WARNING|ERROR`
|
|
128
158
|
|
|
129
159
|
---
|
|
@@ -152,6 +182,6 @@ Preprint: https://arxiv.org/abs/2604.22755
|
|
|
152
182
|
|
|
153
183
|
Copyright 2026 Zavier N. Ndum
|
|
154
184
|
|
|
155
|
-
This project is licensed under the Apache License 2.0. See the [LICENSE](https://github.com/SmartLabNuclear/RADIANT_LLM/blob/main/LICENSE) file in the RADIANT_LLM repository for the full license text.
|
|
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.
|
|
156
186
|
|
|
157
187
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["setuptools>=
|
|
2
|
+
requires = ["setuptools>=77.0.0", "wheel"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "visual-parser"
|
|
7
|
-
version = "2.0
|
|
7
|
+
version = "2.1.0"
|
|
8
8
|
description = "Standalone Visual-RAG PDF Parser - text extraction and Vision-LLM figure descriptions to JSONL"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
11
|
-
license =
|
|
11
|
+
license = "Apache-2.0"
|
|
12
12
|
# PEP 621: name+email in one entry -> Author-email only (Author stays empty on PyPI).
|
|
13
13
|
# Split entries so PyPI/pip show both Author and Author-email.
|
|
14
14
|
authors = [
|
|
@@ -26,7 +26,6 @@ classifiers = [
|
|
|
26
26
|
"Programming Language :: Python :: 3.10",
|
|
27
27
|
"Programming Language :: Python :: 3.11",
|
|
28
28
|
"Programming Language :: Python :: 3.12",
|
|
29
|
-
"License :: OSI Approved :: Apache Software License",
|
|
30
29
|
"Operating System :: OS Independent",
|
|
31
30
|
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
32
31
|
"Topic :: Text Processing :: Markup",
|
|
@@ -34,24 +33,24 @@ classifiers = [
|
|
|
34
33
|
]
|
|
35
34
|
|
|
36
35
|
dependencies = [
|
|
37
|
-
"PyMuPDF
|
|
38
|
-
"Pillow
|
|
39
|
-
"torch
|
|
40
|
-
"transformers
|
|
41
|
-
"huggingface-hub
|
|
42
|
-
"langchain-community
|
|
43
|
-
"langchain
|
|
44
|
-
"langchain-text-splitters
|
|
45
|
-
"openai
|
|
46
|
-
"google-generativeai
|
|
47
|
-
"python-dotenv
|
|
48
|
-
"tqdm
|
|
49
|
-
"nltk>=3.8",
|
|
50
|
-
"python-Levenshtein>=0.20",
|
|
36
|
+
"PyMuPDF>=1.23.0", # fitz -- rasterisation & native text layer
|
|
37
|
+
"Pillow>=10.0.0", # image handling
|
|
38
|
+
"torch>=2.1.0", # CPU build is fine; GPU users install their own wheel -- see README's CUDA note
|
|
39
|
+
"transformers>=4.38.0", # AutoProcessor + VisionEncoderDecoderModel
|
|
40
|
+
"huggingface-hub>=0.36.0", # model download utilities (used by transformers/nougat)
|
|
41
|
+
"langchain-community>=0.0.20", # PyPDFLoader fallback
|
|
42
|
+
"langchain>=0.1.0",
|
|
43
|
+
"langchain-text-splitters>=0.0.1", # RecursiveCharacterTextSplitter (split out from langchain in v0.2+)
|
|
44
|
+
"openai>=1.14.0",
|
|
45
|
+
"google-generativeai>=0.5.0",
|
|
46
|
+
"python-dotenv>=1.0.0",
|
|
47
|
+
"tqdm>=4.66.0",
|
|
48
|
+
"nltk>=3.8", # required by NougatTokenizerFast
|
|
49
|
+
"python-Levenshtein>=0.20", # required by NougatTokenizerFast
|
|
51
50
|
]
|
|
52
51
|
|
|
53
52
|
[project.optional-dependencies]
|
|
54
|
-
ocr = ["pytesseract
|
|
53
|
+
ocr = ["pytesseract>=0.3.10"] # optional equation OCR, requires the Tesseract system binary
|
|
55
54
|
dev = ["pytest", "ruff", "mypy"]
|
|
56
55
|
|
|
57
56
|
[project.urls]
|
|
@@ -54,13 +54,21 @@ def _build_arg_parser() -> argparse.ArgumentParser:
|
|
|
54
54
|
epilog=USAGE_EXAMPLES,
|
|
55
55
|
)
|
|
56
56
|
|
|
57
|
+
from visual_parser import __version__
|
|
58
|
+
p.add_argument(
|
|
59
|
+
"--version", "-V",
|
|
60
|
+
action="version",
|
|
61
|
+
version=f"visual-parser {__version__}",
|
|
62
|
+
)
|
|
63
|
+
|
|
57
64
|
# ---- Paths --------------------------------------------------------------
|
|
58
65
|
io_group = p.add_argument_group("Paths")
|
|
59
66
|
io_group.add_argument(
|
|
60
67
|
"--input-dir", "-i",
|
|
61
|
-
required=
|
|
68
|
+
required=False,
|
|
62
69
|
metavar="DIR",
|
|
63
|
-
help="Directory to scan for PDF files (searched recursively)."
|
|
70
|
+
help="Directory to scan for PDF files (searched recursively). "
|
|
71
|
+
"Required unless --list-models is given.",
|
|
64
72
|
)
|
|
65
73
|
io_group.add_argument(
|
|
66
74
|
"--output-dir", "-o",
|
|
@@ -165,6 +173,17 @@ def _build_arg_parser() -> argparse.ArgumentParser:
|
|
|
165
173
|
|
|
166
174
|
# ---- Misc ---------------------------------------------------------------
|
|
167
175
|
misc_group = p.add_argument_group("Miscellaneous")
|
|
176
|
+
misc_group.add_argument(
|
|
177
|
+
"--list-models",
|
|
178
|
+
action="store_true",
|
|
179
|
+
help=(
|
|
180
|
+
"Print the live, currently-available vision models for gpt and/or "
|
|
181
|
+
"gemini (whichever of OPENAI_API_KEY / GEMINI_API_KEY is set in "
|
|
182
|
+
".env), then exit -- no PDF processing. Replaces the static "
|
|
183
|
+
"example names shown in --vision-model's help text above, which "
|
|
184
|
+
"can go stale as providers add/retire models."
|
|
185
|
+
),
|
|
186
|
+
)
|
|
168
187
|
misc_group.add_argument(
|
|
169
188
|
"--rebuild",
|
|
170
189
|
action="store_true",
|
|
@@ -194,6 +213,55 @@ def _build_arg_parser() -> argparse.ArgumentParser:
|
|
|
194
213
|
return p
|
|
195
214
|
|
|
196
215
|
|
|
216
|
+
def _print_available_models() -> int:
|
|
217
|
+
"""--list-models: print the live vision-model catalog for whichever
|
|
218
|
+
provider(s) have a key configured, then exit. No PDF processing."""
|
|
219
|
+
import os as _os
|
|
220
|
+
|
|
221
|
+
from visual_parser import config as _config # noqa: F401 (triggers _load_env() on import)
|
|
222
|
+
from visual_parser.model_catalog import list_gemini_models, list_openai_models
|
|
223
|
+
from visual_parser.openai_gateway import resolve_openai_connection
|
|
224
|
+
|
|
225
|
+
conn = resolve_openai_connection()
|
|
226
|
+
gemini_key = _os.getenv("GEMINI_API_KEY", "").strip()
|
|
227
|
+
|
|
228
|
+
if not conn["api_key"] and not gemini_key:
|
|
229
|
+
print(
|
|
230
|
+
"[ERROR] None of OPENAI_API_KEY, PORTKEY_API_KEY, or GEMINI_API_KEY "
|
|
231
|
+
"is set (checked ~/.config/visual-parser/.env, the current "
|
|
232
|
+
"directory's .env, and $VISUAL_PARSER_ENV_FILE). Set at least one "
|
|
233
|
+
"to list models.",
|
|
234
|
+
file=sys.stderr,
|
|
235
|
+
)
|
|
236
|
+
return 1
|
|
237
|
+
|
|
238
|
+
if conn["api_key"]:
|
|
239
|
+
via = " (via Portkey)" if conn["base_url"] else ""
|
|
240
|
+
print(f"gpt (OpenAI){via} -- live, currently available:")
|
|
241
|
+
models = list_openai_models(
|
|
242
|
+
conn["api_key"], base_url=conn["base_url"], model_prefix=conn["model_prefix"], force_refresh=True
|
|
243
|
+
)
|
|
244
|
+
if models:
|
|
245
|
+
for model_id in models:
|
|
246
|
+
print(f" {model_id}")
|
|
247
|
+
else:
|
|
248
|
+
print(" (none found -- check the configured key is valid)")
|
|
249
|
+
print()
|
|
250
|
+
|
|
251
|
+
if gemini_key:
|
|
252
|
+
print("gemini (Google) -- live, currently available:")
|
|
253
|
+
models = list_gemini_models(gemini_key, force_refresh=True)
|
|
254
|
+
if models:
|
|
255
|
+
for model_id in models:
|
|
256
|
+
print(f" {model_id}")
|
|
257
|
+
else:
|
|
258
|
+
print(" (none found -- check GEMINI_API_KEY is valid)")
|
|
259
|
+
print()
|
|
260
|
+
|
|
261
|
+
print("Pass one of the above to --vision-model (with the matching --vision-provider).")
|
|
262
|
+
return 0
|
|
263
|
+
|
|
264
|
+
|
|
197
265
|
def main(argv=None) -> int:
|
|
198
266
|
"""
|
|
199
267
|
Parse CLI arguments, build a :class:`~visual_parser.config.ParserConfig`,
|
|
@@ -204,6 +272,12 @@ def main(argv=None) -> int:
|
|
|
204
272
|
parser = _build_arg_parser()
|
|
205
273
|
args = parser.parse_args(argv)
|
|
206
274
|
|
|
275
|
+
if args.list_models:
|
|
276
|
+
return _print_available_models()
|
|
277
|
+
|
|
278
|
+
if not args.input_dir:
|
|
279
|
+
parser.error("--input-dir is required (unless --list-models is given).")
|
|
280
|
+
|
|
207
281
|
# Default vision model per provider when not explicitly set
|
|
208
282
|
if args.vision_model is None:
|
|
209
283
|
args.vision_model = (
|
|
@@ -52,13 +52,21 @@ def _build_arg_parser() -> argparse.ArgumentParser:
|
|
|
52
52
|
epilog=USAGE_EXAMPLES,
|
|
53
53
|
)
|
|
54
54
|
|
|
55
|
+
from visual_parser import __version__
|
|
56
|
+
parser.add_argument(
|
|
57
|
+
"--version", "-V",
|
|
58
|
+
action="version",
|
|
59
|
+
version=f"visual-parser {__version__}",
|
|
60
|
+
)
|
|
61
|
+
|
|
55
62
|
io_group = parser.add_argument_group("Paths")
|
|
56
63
|
io_group.add_argument(
|
|
57
64
|
"--input-dir",
|
|
58
65
|
"-i",
|
|
59
|
-
required=
|
|
66
|
+
required=False,
|
|
60
67
|
metavar="DIR",
|
|
61
|
-
help="Directory to scan for PDF files (searched recursively)."
|
|
68
|
+
help="Directory to scan for PDF files (searched recursively). "
|
|
69
|
+
"Required unless --list-models is given.",
|
|
62
70
|
)
|
|
63
71
|
io_group.add_argument(
|
|
64
72
|
"--output-dir",
|
|
@@ -160,6 +168,17 @@ def _build_arg_parser() -> argparse.ArgumentParser:
|
|
|
160
168
|
)
|
|
161
169
|
|
|
162
170
|
misc_group = parser.add_argument_group("Miscellaneous")
|
|
171
|
+
misc_group.add_argument(
|
|
172
|
+
"--list-models",
|
|
173
|
+
action="store_true",
|
|
174
|
+
help=(
|
|
175
|
+
"Print the live, currently-available vision models for gpt and/or "
|
|
176
|
+
"gemini (whichever of OPENAI_API_KEY / GEMINI_API_KEY is set in "
|
|
177
|
+
".env), then exit -- no PDF processing. Replaces the static "
|
|
178
|
+
"example names shown in --vision-model's help text above, which "
|
|
179
|
+
"can go stale as providers add/retire models."
|
|
180
|
+
),
|
|
181
|
+
)
|
|
163
182
|
misc_group.add_argument(
|
|
164
183
|
"--rebuild",
|
|
165
184
|
action="store_true",
|
|
@@ -193,6 +212,14 @@ def main(argv=None) -> int:
|
|
|
193
212
|
parser = _build_arg_parser()
|
|
194
213
|
args = parser.parse_args(argv)
|
|
195
214
|
|
|
215
|
+
if args.list_models:
|
|
216
|
+
from visual_parser.cli import _print_available_models
|
|
217
|
+
|
|
218
|
+
return _print_available_models()
|
|
219
|
+
|
|
220
|
+
if not args.input_dir:
|
|
221
|
+
parser.error("--input-dir is required (unless --list-models is given).")
|
|
222
|
+
|
|
196
223
|
if args.vision_model is None:
|
|
197
224
|
args.vision_model = (
|
|
198
225
|
"gpt-5.4" if args.vision_provider == "gpt" else "gemini-3-pro-preview"
|