Mungert commited on
Commit
c913b48
·
verified ·
1 Parent(s): ba6cd99

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +286 -0
README.md ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+ license: apache-2.0
4
+ pipeline_tag: image-to-text
5
+ language:
6
+ - en
7
+ - fr
8
+ - de
9
+ - es
10
+ - it
11
+ - nl
12
+ - pt
13
+ - sv
14
+ - da
15
+ base_model: lightonai/LightOnOCR-1B-1025
16
+ library_name: vllm
17
+ tags:
18
+ - ocr
19
+ - document-understanding
20
+ - vision-language
21
+ - pdf
22
+ - tables
23
+ - forms
24
+ ---
25
+
26
+ # <span style="color: #7FFF7F;">LightOnOCR-1B-1025 GGUF Models</span>
27
+
28
+
29
+ ## <span style="color: #7F7FFF;">Model Generation Details</span>
30
+
31
+ This model was generated using [llama.cpp](https://github.com/ggerganov/llama.cpp) at commit [`16724b5b6`](https://github.com/ggerganov/llama.cpp/commit/16724b5b6836a2d4b8936a5824d2ff27c52b4517).
32
+
33
+
34
+
35
+
36
+
37
+
38
+ ---
39
+
40
+ <a href="https://readyforquantum.com/huggingface_gguf_selection_guide.html" style="color: #7FFF7F;">
41
+ Click here to get info on choosing the right GGUF model format
42
+ </a>
43
+
44
+ ---
45
+
46
+
47
+
48
+ <!--Begin Original Model Card-->
49
+
50
+
51
+ <div align="center">
52
+ <img src="lightonocr-banner.png" alt="LightOn OCR-1B Banner" width="400"/>
53
+ </div>
54
+
55
+ # LightOnOCR-1B-1025
56
+
57
+ Full BF16 version of the model. We recommend this variant for inference and further fine-tuning.
58
+
59
+ **LightOnOCR-1B** is a compact, end-to-end vision–language model for Optical Character Recognition (OCR) and document understanding. It achieves state-of-the-art accuracy in its weight class while being several times faster and cheaper than larger general-purpose VLMs.
60
+
61
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/#fileId=https%3A//huggingface.co/lightonai/LightOnOCR-1B-1025/blob/main/notebook.ipynb)
62
+
63
+ 📝 **[Read the full blog post](https://huggingface.co/blog/lightonai/lightonocr/)** | 🚀 **[Try the demo](https://huggingface.co/spaces/lightonai/LightOnOCR-1B-Demo)**
64
+
65
+ **Highlights**
66
+
67
+ * ⚡ **Speed:** 5× faster than dots.ocr, 2× faster than PaddleOCR-VL-0.9B, 1.73× faster than DeepSeekOCR
68
+ * 💸 **Efficiency:** Processes 5.71 pages/s on a single H100 (~493k pages/day) for **<$0.01 per 1,000 pages**
69
+ * 🧠 **End-to-End:** Fully differentiable, no external OCR pipeline
70
+ * 🧾 **Versatile:** Handles tables, receipts, forms, multi-column layouts, and math notation
71
+ * 🌍 **Compact variants:** 32k and 16k vocab options for European languages
72
+
73
+ ---
74
+
75
+ ## Model Overview
76
+
77
+ **LightOnOCR** combines a Vision Transformer encoder(Pixtral-based) with a lightweight text decoder(Qwen3-based) distilled from high-quality open VLMs.
78
+ It is optimized for document parsing tasks, producing accurate, layout-aware text extraction from high-resolution pages.
79
+
80
+
81
+ ---
82
+
83
+ ## Benchmarks
84
+
85
+ | Model | ArXiv | Old Scans | Math | Tables | Multi-Column | Tiny Text | Base | Overall |
86
+ | :----------------- | :---: | :-------: | :--: | :----: | :----------: | :-------: | :--: | :-----: |
87
+ | [LightOnOCR-1B-1025](https://huggingface.co/lightonai/LightOnOCR-1B-1025) (151k vocab) | 81.4 | 71.6 | 76.4 | 35.2 | 80.0 | 88.7 | 99.5 | **76.1** |
88
+ | [LightOnOCR-1B-32k](https://huggingface.co/lightonai/LightOnOCR-0.9B-32k-1025) (32k vocab) | 80.6 | 66.2 | 73.5 | 33.5 | 71.2 | 87.6 | 99.5 | **73.1** |
89
+ | [LightOnOCR-1B-16k](https://huggingface.co/lightonai/LightOnOCR-0.9B-16k-1025) (16k vocab) | 82.3 | 72.9 | 75.3 | 33.5 | 78.6 | 85.1 | 99.8 | **75.4** |
90
+
91
+ All benchmarks evaluated using **vLLM** on the Olmo-Bench.
92
+
93
+ ---
94
+
95
+ ## Installation
96
+
97
+ ```bash
98
+
99
+ uv venv --python 3.12 --seed
100
+ source .venv/bin/activate
101
+
102
+ uv pip install -U vllm \
103
+ --torch-backend=auto \
104
+ --extra-index-url https://wheels.vllm.ai/nightly \
105
+ --prerelease=allow
106
+
107
+ # if this fails try adding triton-kernels package
108
+ 'triton-kernels @ git+https://github.com/triton-lang/triton.git@v3.5.0#subdirectory=python/triton_kernels'
109
+ uv pip install pypdfium2 pillow requests
110
+ ```
111
+
112
+ ## Start Server
113
+
114
+ ```bash
115
+ vllm serve lightonai/LightOnOCR-1B-1025 \
116
+ --limit-mm-per-prompt '{"image": 1}' \
117
+ --async-scheduling
118
+ ```
119
+
120
+ ## PDF Inference
121
+
122
+ ```python
123
+ import base64
124
+ import requests
125
+ import pypdfium2 as pdfium
126
+ import io
127
+
128
+ ENDPOINT = "http://localhost:8000/v1/chat/completions"
129
+ MODEL = "lightonai/LightOnOCR-1B-1025"
130
+
131
+ # Download PDF from arXiv
132
+ pdf_url = "https://arxiv.org/pdf/2412.13663"
133
+ pdf_data = requests.get(pdf_url).content
134
+
135
+ # Open PDF and convert first page to image
136
+ pdf = pdfium.PdfDocument(pdf_data)
137
+ page = pdf[0]
138
+ # Render at 200 DPI (scale factor = 200/72 ≈ 2.77)
139
+ pil_image = page.render(scale=2.77).to_pil()
140
+
141
+ # Convert to base64
142
+ buffer = io.BytesIO()
143
+ pil_image.save(buffer, format="PNG")
144
+ image_base64 = base64.b64encode(buffer.getvalue()).decode('utf-8')
145
+
146
+ # Make request
147
+ payload = {
148
+ "model": MODEL,
149
+ "messages": [{
150
+ "role": "user",
151
+ "content": [{
152
+ "type": "image_url",
153
+ "image_url": {"url": f"data:image/png;base64,{image_base64}"}
154
+ }]
155
+ }],
156
+ "max_tokens": 4096,
157
+ "temperature": 0.2,
158
+ "top_p": 0.9,
159
+ }
160
+
161
+ response = requests.post(ENDPOINT, json=payload)
162
+ text = response.json()['choices'][0]['message']['content']
163
+ print(text)
164
+ ```
165
+ ---
166
+
167
+ ## Rendering and Preprocessing Tips
168
+
169
+ * Render PDFs to **PNG** or **JPEG** at a target longest dimension of **1540px**
170
+ * Maintain aspect ratio to preserve text geometry
171
+ * Use one image per page; batching supported by vLLM
172
+
173
+ ---
174
+
175
+ ## Variants
176
+
177
+ | Variant | Description |
178
+ | :--------------------------------------------------------------------------------- | :-------------------------------------------- |
179
+ | **[LightOnOCR-1B-1025](https://huggingface.co/lightonai/LightOnOCR-1B-1025)** | Full multilingual model (default) |
180
+ | **[LightOnOCR-1B-32k](https://huggingface.co/lightonai/LightOnOCR-0.9B-32k-1025)** | Fastest pruned-vocabulary version (32k tokens) optimized for European languages |
181
+ | **[LightOnOCR-1B-16k](https://huggingface.co/lightonai/LightOnOCR-0.9B-16k-1025)** | Most compact variant with smallest vocabulary |
182
+
183
+ ---
184
+
185
+ ## Fine-tuning
186
+
187
+ **Transformers integration is coming soon for training and inference.**
188
+
189
+ LightOnOCR is fully differentiable and supports:
190
+
191
+ * LoRA fine-tuning
192
+ * Domain adaptation (receipts, scientific articles, forms, etc.)
193
+ * Multilingual fine-tuning with task-specific corpora
194
+
195
+
196
+ Example fine-tuning configurations will be released alongside the dataset.
197
+
198
+ ---
199
+
200
+ ## Data
201
+
202
+ Trained on a diverse large-scale PDF corpus covering:
203
+
204
+ * Scientific papers, books, receipts, invoices, tables, forms, and handwritten text
205
+ * Multiple languages (Latin alphabet dominant)
206
+ * Real and synthetic document scans
207
+
208
+ The dataset will be released under an open license.
209
+
210
+ ---
211
+
212
+ ## License
213
+
214
+ Apache License 2.0
215
+
216
+ ---
217
+
218
+ ## Citation
219
+
220
+ ```
221
+ @misc{lightonocr2025,
222
+ title = {LightOnOCR-1B: End-to-End and Efficient Domain-Specific Vision-Language Models for OCR},
223
+ author = {Said Taghadouini and Baptiste Aubertin and Adrien Cavaillès},
224
+ year = {2025},
225
+ howpublished = {\url{https://huggingface.co/blog/lightonai/lightonocr}}
226
+ }
227
+ ```
228
+
229
+ <!--End Original Model Card-->
230
+
231
+ ---
232
+
233
+ # <span id="testllm" style="color: #7F7FFF;">🚀 If you find these models useful</span>
234
+
235
+ Help me test my **AI-Powered Quantum Network Monitor Assistant** with **quantum-ready security checks**:
236
+
237
+ 👉 [Quantum Network Monitor](https://readyforquantum.com/?assistant=open&utm_source=huggingface&utm_medium=referral&utm_campaign=huggingface_repo_readme)
238
+
239
+
240
+ The full Open Source Code for the Quantum Network Monitor Service available at my github repos ( repos with NetworkMonitor in the name) : [Source Code Quantum Network Monitor](https://github.com/Mungert69). You will also find the code I use to quantize the models if you want to do it yourself [GGUFModelBuilder](https://github.com/Mungert69/GGUFModelBuilder)
241
+
242
+ 💬 **How to test**:
243
+ Choose an **AI assistant type**:
244
+ - `TurboLLM` (GPT-4.1-mini)
245
+ - `HugLLM` (Hugginface Open-source models)
246
+ - `TestLLM` (Experimental CPU-only)
247
+
248
+ ### **What I’m Testing**
249
+ I’m pushing the limits of **small open-source models for AI network monitoring**, specifically:
250
+ - **Function calling** against live network services
251
+ - **How small can a model go** while still handling:
252
+ - Automated **Nmap security scans**
253
+ - **Quantum-readiness checks**
254
+ - **Network Monitoring tasks**
255
+
256
+ 🟡 **TestLLM** – Current experimental model (llama.cpp on 2 CPU threads on huggingface docker space):
257
+ - ✅ **Zero-configuration setup**
258
+ - ⏳ 30s load time (slow inference but **no API costs**) . No token limited as the cost is low.
259
+ - 🔧 **Help wanted!** If you’re into **edge-device AI**, let’s collaborate!
260
+
261
+ ### **Other Assistants**
262
+ 🟢 **TurboLLM** – Uses **gpt-4.1-mini** :
263
+ - **It performs very well but unfortunatly OpenAI charges per token. For this reason tokens usage is limited.
264
+ - **Create custom cmd processors to run .net code on Quantum Network Monitor Agents**
265
+ - **Real-time network diagnostics and monitoring**
266
+ - **Security Audits**
267
+ - **Penetration testing** (Nmap/Metasploit)
268
+
269
+ 🔵 **HugLLM** – Latest Open-source models:
270
+ - 🌐 Runs on Hugging Face Inference API. Performs pretty well using the lastest models hosted on Novita.
271
+
272
+ ### 💡 **Example commands you could test**:
273
+ 1. `"Give me info on my websites SSL certificate"`
274
+ 2. `"Check if my server is using quantum safe encyption for communication"`
275
+ 3. `"Run a comprehensive security audit on my server"`
276
+ 4. '"Create a cmd processor to .. (what ever you want)" Note you need to install a [Quantum Network Monitor Agent](https://readyforquantum.com/Download/?utm_source=huggingface&utm_medium=referral&utm_campaign=huggingface_repo_readme) to run the .net code on. This is a very flexible and powerful feature. Use with caution!
277
+
278
+ ### Final Word
279
+
280
+ I fund the servers used to create these model files, run the Quantum Network Monitor service, and pay for inference from Novita and OpenAI—all out of my own pocket. All the code behind the model creation and the Quantum Network Monitor project is [open source](https://github.com/Mungert69). Feel free to use whatever you find helpful.
281
+
282
+ If you appreciate the work, please consider [buying me a coffee](https://www.buymeacoffee.com/mahadeva) ☕. Your support helps cover service costs and allows me to raise token limits for everyone.
283
+
284
+ I'm also open to job opportunities or sponsorship.
285
+
286
+ Thank you! 😊