yafitzdev commited on
Commit
bb30f05
·
verified ·
1 Parent(s): bd773d3

Align Opsis g2 model card with Pyrrho house style

Browse files

Standardize layout, contracts, quick start, evaluation, artifacts, limitations, and license presentation.

Files changed (1) hide show
  1. README.md +207 -62
README.md CHANGED
@@ -7,62 +7,160 @@ pipeline_tag: image-text-to-text
7
  language:
8
  - en
9
  tags:
10
- - pyrrho
11
- - opsis
12
  - rag
 
13
  - image-to-text
14
  - document-ai
15
  - table-recognition
 
 
16
  - onnx
17
  - cpu
18
  ---
19
 
20
- # Pyrrho Opsis v1 nano g2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- Pyrrho Opsis is a small local visual-ingestion co-processor for RAG systems. It converts one image
23
- into either concise discovery text or a GitHub-flavored Markdown table. Charts and diagrams are
24
- described with visible labels, values, and relationships. It is designed to let retrieval systems
25
- index visual PDF regions without a hosted VLM API or inference GPU.
26
 
27
- This is a research preview, not an authoritative OCR or financial/scientific extraction system.
 
 
28
 
29
- ## Intended use
30
 
31
- - enrich image, chart, diagram, and table crops with searchable RAG text;
32
- - run locally through ONNX Runtime on CPU;
33
- - route native PDF text around the model and send only visual regions through Opsis;
34
- - preserve the source image/page alongside generated text for verification.
35
 
36
- Do not treat generated numbers or table cells as ground truth. Do not use it for safety-critical
37
- decisions without independent source verification.
 
 
38
 
39
- ## Output contract
40
 
41
- Input: one raster image.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- Output:
 
 
 
 
 
44
 
45
- - `<description>concise factual text</description>` for ordinary images, charts, and diagrams;
46
- - `<table>...Markdown table...</table>` for table images.
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
- The packaged parser strips the wrapper tags from its public result.
 
 
49
 
50
- ## Model
51
 
52
- - base architecture: SmolVLM-256M-Instruct;
53
- - immediate parent checkpoint: Pyrrho Opsis v1 nano g1;
54
- - generation: Pyrrho Opsis v1 nano g2;
55
- - total parameters: 258,099,264;
56
- - adapted parameters: 1,614,336 (0.625%);
57
- - LoRA targets: text attention, vision attention, and the vision-to-text connector;
58
- - training resolution: 1024-pixel longest edge.
59
 
60
- G2 retains the v1 capability and output contract. It is generation 2 because it changes data
61
- balance and vision adaptation, not the fundamental task or heads.
 
 
 
62
 
63
- ## CPU usage
 
 
 
 
 
 
 
 
64
 
65
- With the `rag-image-parser` project installed:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  ```powershell
68
  uv run rag-image-parse parse .\image.png `
@@ -73,47 +171,94 @@ uv run rag-image-parse parse .\image.png `
73
  --image-longest-edge 1024
74
  ```
75
 
76
- FP32 ONNX is the recommended and packaged artifact. Mixed INT8 reduced routing and Markdown
77
- validity in evaluation and is not included in this repository.
78
 
79
  ## Evaluation
80
 
81
- On a 50-case, source-held-out automatic comparison containing ten examples each from tables,
82
- charts, diagrams, ordinary images, and PDF-domain crops:
83
 
84
  | Metric | G1 | G2 |
85
  |---|---:|---:|
86
- | Kind accuracy | 100% | 100% |
87
- | Valid Markdown tables | 100% | 100% |
88
- | Exact tables | 0% | 7.1% |
89
- | Correct table shape | 21.4% | 42.9% |
90
- | Mean table cell F1 | 31.0% | 50.5% |
91
- | Required-term recall | 53.8% | 57.7% |
92
- | Directed-relation recall | 34.0% | 48.7% |
93
- | Median CPU latency | 3.71 s | 3.72 s |
94
  | p95 CPU latency | 16.74 s | 10.95 s |
95
- | Peak process RSS | 2,377 MiB | 2,382 MiB |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
- This benchmark is automatically labeled and too small for a product-quality claim. Exact table
98
- accuracy remains low.
99
 
100
- ## Training data
101
 
102
- G2 trained on 50,000 rendered files:
 
 
 
 
 
 
103
 
104
- - 12,500 clean tables;
105
- - 6,250 clean charts;
106
- - 6,250 clean diagrams;
107
- - 12,500 clean ordinary images;
108
- - 12,500 PDF-style crops balanced across the four content types.
109
 
110
- Sources include PubTabNet, ChartQA, AI2D, and DOCCI. Charts, diagrams, and ordinary images use
111
- deterministic label-preserving variants because their strict unique-source pools are smaller than
112
- the rendered file counts.
 
 
 
 
 
 
 
 
 
113
 
114
  ## License
115
 
116
- Mixed-source research preview. The training mixture includes research-restricted AI2D data and
117
- sources with separate attribution, redistribution, or underlying-image terms. This package must
118
- not be represented as commercially cleared. Review and satisfy every source obligation before
119
- making the repository public or using the weights commercially.
 
 
7
  language:
8
  - en
9
  tags:
 
 
10
  - rag
11
+ - visual-ingestion
12
  - image-to-text
13
  - document-ai
14
  - table-recognition
15
+ - pyrrho
16
+ - opsis
17
  - onnx
18
  - cpu
19
  ---
20
 
21
+ # pyrrho-opsis-v1-nano-g2
22
+
23
+ `pyrrho-opsis-v1-nano-g2` is a small local RAG visual-ingestion co-processor. It
24
+ runs on one image or document crop and returns either concise discovery text or
25
+ a GitHub-flavored Markdown table for downstream indexing and retrieval.
26
+
27
+ It is not a general-purpose assistant, not a replacement for native PDF text
28
+ extraction, and not an authoritative OCR system. It sits before indexing, or
29
+ beside a PDF routing pipeline, so visual content can become searchable without
30
+ a hosted VLM API or inference GPU.
31
+
32
+ Compared with `pyrrho-opsis-v1-nano-g1`, g2 keeps the same v1 capability and
33
+ output contract while moving to a balanced 50,000-file corpus and adapting the
34
+ vision encoder in addition to text attention and the vision-to-text connector.
35
+ G2 is the recommended Opsis v1 nano generation.
36
+
37
+ ## Native V1 Output Modes
38
 
39
+ | Mode | Native output | Intended use |
40
+ |---|---|---|
41
+ | `description` | `<description>concise factual text</description>` | Ordinary images, charts, and diagrams that need searchable RAG metadata. |
42
+ | `table` | `<table>GitHub-flavored Markdown table</table>` | Table images that need recoverable rows and cells rather than prose. |
43
 
44
+ Charts stay in `description` mode and should include visible labels, values,
45
+ and trends. Diagrams stay in `description` mode and should include visible
46
+ nodes and relationships.
47
 
48
+ ## Output Contract
49
 
50
+ The raw Hugging Face model output is one tagged string. It is not unrestricted
51
+ assistant prose. Decode it by wrapper:
 
 
52
 
53
+ | Wrapper | Parsed kind | Decoding |
54
+ |---|---|---|
55
+ | `<description>...</description>` | `description` | Strip the wrapper and retain concise factual text. |
56
+ | `<table>...</table>` | `table` | Strip the wrapper and retain the complete Markdown table. |
57
 
58
+ The companion parser normalizes either result into one object:
59
 
60
+ ```json
61
+ {
62
+ "kind": "description",
63
+ "text": "A line chart shows quarterly revenue rising from $12M in Q1 to $18M in Q4.",
64
+ "latency_seconds": 3.72,
65
+ "model_id": "yafitzdev/pyrrho-opsis-v1-nano-g2",
66
+ "prompt_version": "rag-image-v3"
67
+ }
68
+ ```
69
+
70
+ The model does not return bounding boxes, OCR confidence, source coordinates,
71
+ PDF text blocks, or verified numeric facts. Preserve the source image or page
72
+ crop beside generated text when exact visual evidence matters.
73
+
74
+ ## Intended Use
75
+
76
+ Use this model when a RAG or retrieval system needs local visual signals for:
77
 
78
+ - indexing ordinary images with concise discovery descriptions,
79
+ - converting compact table images into Markdown,
80
+ - recording visible chart labels, values, and trends,
81
+ - recording labeled diagram nodes and relationships,
82
+ - enriching visual regions routed out of otherwise native-text PDFs,
83
+ - keeping document ingestion local on CPU-only systems.
84
 
85
+ This model is not intended to replace reliable native table extraction, parse
86
+ full scanned pages as a layout engine, verify high-stakes measurements, or
87
+ replace source review when exact cells and labels matter.
88
+
89
+ ## Input Format
90
+
91
+ The model accepts one raster image per inference. For direct Transformers use,
92
+ pair the image with the v1 parser prompt:
93
+
94
+ ```text
95
+ Parse this image for RAG search. If it is a table, output only the complete
96
+ table as Markdown. Otherwise output only a concise factual description. Include
97
+ meaningful visible text. For a diagram, name its labels and relationships. For
98
+ a chart, mention its labels, values, and trend. Do not speculate or add a heading.
99
+ ```
100
 
101
+ For PDFs, extract reliable native text normally and send only table, image,
102
+ chart, or diagram regions to Opsis. Crop quality and readable resolution have a
103
+ direct effect on output quality.
104
 
105
+ ## Quick Start
106
 
107
+ ```python
108
+ import torch
109
+ from PIL import Image
110
+ from transformers import AutoModelForImageTextToText, AutoProcessor
 
 
 
111
 
112
+ MODEL_ID = "yafitzdev/pyrrho-opsis-v1-nano-g2"
113
+ PROMPT = """Parse this image for RAG search. If it is a table, output only the complete
114
+ table as Markdown. Otherwise output only a concise factual description. Include meaningful
115
+ visible text. For a diagram, name its labels and relationships. For a chart, mention its labels,
116
+ values, and trend. Do not speculate or add a heading."""
117
 
118
+ processor = AutoProcessor.from_pretrained(
119
+ MODEL_ID,
120
+ size={"longest_edge": 1024},
121
+ )
122
+ model = AutoModelForImageTextToText.from_pretrained(
123
+ MODEL_ID,
124
+ dtype=torch.float32,
125
+ ).eval()
126
+ image = Image.open("image.png").convert("RGB")
127
 
128
+ messages = [{
129
+ "role": "user",
130
+ "content": [
131
+ {"type": "image"},
132
+ {"type": "text", "text": PROMPT},
133
+ ],
134
+ }]
135
+ prompt_text = processor.apply_chat_template(
136
+ messages,
137
+ add_generation_prompt=True,
138
+ tokenize=False,
139
+ )
140
+ inputs = processor(text=prompt_text, images=[image], return_tensors="pt")
141
+
142
+ with torch.no_grad():
143
+ output_ids = model.generate(
144
+ **inputs,
145
+ do_sample=False,
146
+ max_new_tokens=768,
147
+ repetition_penalty=1.05,
148
+ )
149
+
150
+ generated = output_ids[:, inputs["input_ids"].shape[-1]:]
151
+ text = processor.batch_decode(generated, skip_special_tokens=True)[0]
152
+ print(text)
153
+ ```
154
+
155
+ ## CPU ONNX
156
+
157
+ The repository includes the quality-preserving split FP32 ONNX runtime:
158
+
159
+ - `onnx/vision_encoder.onnx`
160
+ - `onnx/embed_tokens.onnx`
161
+ - `onnx/decoder_model_merged.onnx`
162
+
163
+ With the `rag-image-parser` project installed, run:
164
 
165
  ```powershell
166
  uv run rag-image-parse parse .\image.png `
 
171
  --image-longest-edge 1024
172
  ```
173
 
174
+ Mixed INT8 reduced routing and Markdown validity in evaluation and is not
175
+ included in this repository.
176
 
177
  ## Evaluation
178
 
179
+ Source-held-out automatic evaluation on 50 cases containing ten examples each
180
+ from tables, charts, diagrams, ordinary images, and PDF-domain crops:
181
 
182
  | Metric | G1 | G2 |
183
  |---|---:|---:|
184
+ | kind accuracy | 1.0000 | 1.0000 |
185
+ | valid Markdown tables | 1.0000 | 1.0000 |
186
+ | exact tables | 0.0000 | 0.0714 |
187
+ | correct table shape | 0.2143 | 0.4286 |
188
+ | mean table cell F1 | 0.3103 | 0.5047 |
189
+ | required-term recall | 0.5382 | 0.5773 |
190
+ | directed-relation recall | 0.3397 | 0.4872 |
191
+ | median CPU latency | 3.71 s | 3.72 s |
192
  | p95 CPU latency | 16.74 s | 10.95 s |
193
+ | peak process RSS | 2,377 MiB | 2,382 MiB |
194
+
195
+ Bucket-level checkpoint comparison:
196
+
197
+ | Benchmark slice | G1 | G2 |
198
+ |---|---:|---:|
199
+ | clean-table cell F1 | 0.3928 | 0.5459 |
200
+ | PDF-domain table cell F1 | 0.1040 | 0.4017 |
201
+ | chart required-term recall | 0.7989 | 0.8178 |
202
+ | diagram required-term recall | 0.5207 | 0.6443 |
203
+ | diagram directed-relation recall | 0.3583 | 0.4917 |
204
+ | ordinary-image required-term recall | 0.3375 | 0.3250 |
205
+
206
+ The benchmark is automatically labeled and too small for a product-quality
207
+ claim. G2 materially improved tables, diagrams, and PDF-domain crops; ordinary-
208
+ image term recall was approximately flat.
209
+
210
+ ## Training Data
211
+
212
+ | Training bucket | Files | Validation files | Role |
213
+ |---|---:|---:|---|
214
+ | clean tables | 12,500 | 250 | Compact table image to Markdown. |
215
+ | clean charts | 6,250 | 125 | Chart labels, values, and trends. |
216
+ | clean diagrams | 6,250 | 125 | Diagram nodes and relationships. |
217
+ | clean ordinary images | 12,500 | 250 | Ordinary-image discovery descriptions. |
218
+ | PDF-style visual crops | 12,500 | 250 | Document-domain versions balanced across all four content types. |
219
+ | **Total** | **50,000** | **1,000** | Source-held-out balanced visual parsing. |
220
+
221
+ Sources include PubTabNet, ChartQA, AI2D, and DOCCI. After distributing the PDF
222
+ bucket, the effective training mix is 15,625 tables, 9,375 charts, 9,375
223
+ diagrams, and 15,625 ordinary images. Deterministic label-preserving variants
224
+ expand source pools that contain fewer strict unique examples than the rendered
225
+ file targets.
226
+
227
+ Training used LoRA rank 8 with alpha 16 for one epoch at a 1024-pixel longest
228
+ edge. It updated 1,614,336 of 258,099,264 parameters (0.625%), including text
229
+ attention, vision attention, and the vision-to-text connector.
230
 
231
+ ## Artifacts
 
232
 
233
+ This repository contains:
234
 
235
+ - `model.safetensors`: standalone merged Transformers checkpoint,
236
+ - `onnx/vision_encoder.onnx`: FP32 vision encoder and connector,
237
+ - `onnx/embed_tokens.onnx`: FP32 token embedding graph,
238
+ - `onnx/decoder_model_merged.onnx`: FP32 autoregressive decoder,
239
+ - tokenizer, processor, generation, and model configuration files,
240
+ - `rag_image_parser_config.json`: Opsis release and training metadata,
241
+ - `SHA256SUMS`: checksums for the packaged ONNX graphs.
242
 
243
+ ## Limitations
 
 
 
 
244
 
245
+ 1. **Exact table recovery remains low.** G2 improved table structure and cell
246
+ F1, but exact table accuracy was 7.1% on the small held-out benchmark.
247
+ 2. **Evaluation is small and automatically labeled.** The 50-case benchmark is
248
+ useful for checkpoint comparison, not broad product certification.
249
+ 3. **Generated labels and values can be wrong.** Descriptions and cells are RAG
250
+ discovery metadata, not verified evidence.
251
+ 4. **English-centric mixed-source training.** Multilingual behavior is not
252
+ established, and some source pools use deterministic augmentation.
253
+ 5. **Crop quality matters.** Tiny text, dense pages, poor scans, and incorrect
254
+ visual-region routing reduce performance.
255
+ 6. **CPU latency varies by image complexity.** Dense tables and long outputs can
256
+ be substantially slower than the reported median.
257
 
258
  ## License
259
 
260
+ Mixed-source research preview. The training mixture includes research-restricted
261
+ AI2D data and sources with separate attribution, redistribution, or underlying-
262
+ image terms. This package must not be represented as commercially cleared.
263
+ Review and satisfy every source obligation before making the repository public
264
+ or using the weights commercially.