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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- multilingual
|
| 4 |
+
base_model:
|
| 5 |
+
- Qwen/Qwen2-VL-2B-Instruct
|
| 6 |
+
tags:
|
| 7 |
+
- OCR
|
| 8 |
+
- image-to-text
|
| 9 |
+
- pdf2markdown
|
| 10 |
+
- VQA
|
| 11 |
+
pipeline_tag: image-text-to-text
|
| 12 |
+
license: apache-2.0
|
| 13 |
+
library_name: transformers
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# <span style="color: #7FFF7F;">Nanonets-OCR2-1.5B-exp GGUF Models</span>
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
## <span style="color: #7F7FFF;">Model Generation Details</span>
|
| 20 |
+
|
| 21 |
+
This model was generated using [llama.cpp](https://github.com/ggerganov/llama.cpp) at commit [`03792ad93`](https://github.com/ggerganov/llama.cpp/commit/03792ad93609fc67e41041c6347d9aa14e5e0d74).
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
---
|
| 29 |
+
|
| 30 |
+
<a href="https://readyforquantum.com/huggingface_gguf_selection_guide.html" style="color: #7FFF7F;">
|
| 31 |
+
Click here to get info on choosing the right GGUF model format
|
| 32 |
+
</a>
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
<!--Begin Original Model Card-->
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
<div align="center">
|
| 43 |
+
<p align="center">
|
| 44 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/626d198986671a29c70e688e/Vn6092flX4bQgzal2X04f.png" width="200" style="border-radius: 15px;"/>
|
| 45 |
+
<p>
|
| 46 |
+
<h1 align="center">
|
| 47 |
+
Nanonets-OCR2: A model for transforming documents into structured markdown with intelligent content recognition and semantic tagging
|
| 48 |
+
</h1>
|
| 49 |
+
|
| 50 |
+
<div align="center">
|
| 51 |
+
<a href="https://docstrange.nanonets.com/" target="_blank"><strong>🖥️ Live Demo</strong></a> |
|
| 52 |
+
<a href="https://nanonets.com/research/nanonets-ocr-2/" target="_blank"><strong>📢 Blog</strong></a> |
|
| 53 |
+
<a href="https://github.com/NanoNets/docstrange" target="_blank"><strong>⌨️ GitHub</strong></a>
|
| 54 |
+
</div>
|
| 55 |
+
|
| 56 |
+
</div>
|
| 57 |
+
|
| 58 |
+
Nanonets-OCR2 by [Nanonets](https://nanonets.com) is a family of powerful, state-of-the-art image-to-markdown OCR models that go far beyond traditional text extraction. It transforms documents into structured markdown with intelligent content recognition and semantic tagging, making it ideal for downstream processing by Large Language Models (LLMs).
|
| 59 |
+
|
| 60 |
+
Nanonets-OCR2 is packed with features designed to handle complex documents with ease:
|
| 61 |
+
|
| 62 |
+
* **LaTeX Equation Recognition:** Automatically converts mathematical equations and formulas into properly formatted LaTeX syntax. It distinguishes between inline (`$...$`) and display (`$$...$$`) equations.
|
| 63 |
+
* **Intelligent Image Description:** Describes images within documents using structured `<img>` tags, making them digestible for LLM processing. It can describe various image types, including logos, charts, graphs and so on, detailing their content, style, and context.
|
| 64 |
+
* **Signature Detection & Isolation:** Identifies and isolates signatures from other text, outputting them within a `<signature>` tag. This is crucial for processing legal and business documents.
|
| 65 |
+
* **Watermark Extraction:** Detects and extracts watermark text from documents, placing it within a `<watermark>` tag.
|
| 66 |
+
* **Smart Checkbox Handling:** Converts form checkboxes and radio buttons into standardized Unicode symbols (`☐`, `☑`, `☒`) for consistent and reliable processing.
|
| 67 |
+
* **Complex Table Extraction:** Accurately extracts complex tables from documents and converts them into both markdown and HTML table formats.
|
| 68 |
+
* **Flow charts & Organisational charts:** Extracts flow charts and organisational as [mermaid](mermaid.js.org) code.
|
| 69 |
+
* **Handwritten Documents:** The model is trained on handwritten documents across multiple languages.
|
| 70 |
+
* **Multilingual:** Model is trained on documents of multiple languages, including English, Chinese, French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Arabic, and many more.
|
| 71 |
+
* **Visual Question Answering (VQA):** The model is designed to provide the answer directly if it is present in the document; otherwise, it responds with "Not mentioned."
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
## Nanonets-OCR2 Family
|
| 75 |
+
| Model | Access Link |
|
| 76 |
+
| -----|-----|
|
| 77 |
+
| Nanonets-OCR2-Plus | [Docstrange link](https://docstrange.nanonets.com/) |
|
| 78 |
+
| Nanonets-OCR2-3B | [🤗 link](https://huggingface.co/nanonets/Nanonets-OCR2-3B) |
|
| 79 |
+
| Nanonets-OCR2-1.5B-exp | [🤗 link](https://huggingface.co/nanonets/Nanonets-OCR2-1.5B-exp) |
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
## Usage
|
| 83 |
+
### Using transformers
|
| 84 |
+
```python
|
| 85 |
+
from PIL import Image
|
| 86 |
+
from transformers import AutoTokenizer, AutoProcessor, AutoModelForImageTextToText
|
| 87 |
+
|
| 88 |
+
model_path = "nanonets/Nanonets-OCR2-3B"
|
| 89 |
+
|
| 90 |
+
model = AutoModelForImageTextToText.from_pretrained(
|
| 91 |
+
model_path,
|
| 92 |
+
torch_dtype="auto",
|
| 93 |
+
device_map="auto",
|
| 94 |
+
attn_implementation="flash_attention_2"
|
| 95 |
+
)
|
| 96 |
+
model.eval()
|
| 97 |
+
|
| 98 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 99 |
+
processor = AutoProcessor.from_pretrained(model_path)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def ocr_page_with_nanonets_s(image_path, model, processor, max_new_tokens=4096):
|
| 103 |
+
prompt = """Extract the text from the above document as if you were reading it naturally. Return the tables in html format. Return the equations in LaTeX representation. If there is an image in the document and image caption is not present, add a small description of the image inside the <img></img> tag; otherwise, add the image caption inside <img></img>. Watermarks should be wrapped in brackets. Ex: <watermark>OFFICIAL COPY</watermark>. Page numbers should be wrapped in brackets. Ex: <page_number>14</page_number> or <page_number>9/22</page_number>. Prefer using ☐ and ☑ for check boxes."""
|
| 104 |
+
image = Image.open(image_path)
|
| 105 |
+
messages = [
|
| 106 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 107 |
+
{"role": "user", "content": [
|
| 108 |
+
{"type": "image", "image": f"file://{image_path}"},
|
| 109 |
+
{"type": "text", "text": prompt},
|
| 110 |
+
]},
|
| 111 |
+
]
|
| 112 |
+
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 113 |
+
inputs = processor(text=[text], images=[image], padding=True, return_tensors="pt")
|
| 114 |
+
inputs = inputs.to(model.device)
|
| 115 |
+
|
| 116 |
+
output_ids = model.generate(**inputs, max_new_tokens=max_new_tokens, do_sample=False)
|
| 117 |
+
generated_ids = [output_ids[len(input_ids):] for input_ids, output_ids in zip(inputs.input_ids, output_ids)]
|
| 118 |
+
|
| 119 |
+
output_text = processor.batch_decode(generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True)
|
| 120 |
+
return output_text[0]
|
| 121 |
+
|
| 122 |
+
image_path = "/path/to/your/document.jpg"
|
| 123 |
+
result = ocr_page_with_nanonets_s(image_path, model, processor, max_new_tokens=15000)
|
| 124 |
+
print(result)
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
### Using vLLM
|
| 128 |
+
1. Start the vLLM server.
|
| 129 |
+
```bash
|
| 130 |
+
vllm serve nanonets/Nanonets-OCR2-3B
|
| 131 |
+
```
|
| 132 |
+
2. Predict with the model
|
| 133 |
+
```python
|
| 134 |
+
from openai import OpenAI
|
| 135 |
+
import base64
|
| 136 |
+
|
| 137 |
+
client = OpenAI(api_key="123", base_url="http://localhost:8000/v1")
|
| 138 |
+
|
| 139 |
+
model = "nanonets/Nanonets-OCR2-3B"
|
| 140 |
+
|
| 141 |
+
def encode_image(image_path):
|
| 142 |
+
with open(image_path, "rb") as image_file:
|
| 143 |
+
return base64.b64encode(image_file.read()).decode("utf-8")
|
| 144 |
+
|
| 145 |
+
def ocr_page_with_nanonets_s(img_base64):
|
| 146 |
+
response = client.chat.completions.create(
|
| 147 |
+
model=model,
|
| 148 |
+
messages=[
|
| 149 |
+
{
|
| 150 |
+
"role": "user",
|
| 151 |
+
"content": [
|
| 152 |
+
{
|
| 153 |
+
"type": "image_url",
|
| 154 |
+
"image_url": {"url": f"data:image/png;base64,{img_base64}"},
|
| 155 |
+
},
|
| 156 |
+
{
|
| 157 |
+
"type": "text",
|
| 158 |
+
"text": "Extract the text from the above document as if you were reading it naturally. Return the tables in html format. Return the equations in LaTeX representation. If there is an image in the document and image caption is not present, add a small description of the image inside the <img></img> tag; otherwise, add the image caption inside <img></img>. Watermarks should be wrapped in brackets. Ex: <watermark>OFFICIAL COPY</watermark>. Page numbers should be wrapped in brackets. Ex: <page_number>14</page_number> or <page_number>9/22</page_number>. Prefer using ☐ and ☑ for check boxes.",
|
| 159 |
+
},
|
| 160 |
+
],
|
| 161 |
+
}
|
| 162 |
+
],
|
| 163 |
+
temperature=0.0,
|
| 164 |
+
max_tokens=15000
|
| 165 |
+
)
|
| 166 |
+
return response.choices[0].message.content
|
| 167 |
+
|
| 168 |
+
test_img_path = "/path/to/your/document.jpg"
|
| 169 |
+
img_base64 = encode_image(test_img_path)
|
| 170 |
+
print(ocr_page_with_nanonets_s(img_base64))
|
| 171 |
+
```
|
| 172 |
+
|
| 173 |
+
### Using Docstrange
|
| 174 |
+
|
| 175 |
+
```python
|
| 176 |
+
import requests
|
| 177 |
+
|
| 178 |
+
url = "https://extraction-api.nanonets.com/extract"
|
| 179 |
+
headers = {"Authorization": <API KEY>}
|
| 180 |
+
|
| 181 |
+
files = {"file": open("/path/to/your/file", "rb")}
|
| 182 |
+
data = {"output_type": "markdown"}
|
| 183 |
+
data["model"] = "nanonets"
|
| 184 |
+
|
| 185 |
+
response = requests.post(url, headers=headers, files=files, data=data)
|
| 186 |
+
print(response.json())
|
| 187 |
+
````
|
| 188 |
+
|
| 189 |
+
Check out [Docstrange](https://docstrange.nanonets.com/) for more details.
|
| 190 |
+
|
| 191 |
+
## Evaluation
|
| 192 |
+
### Markdown Evaluations
|
| 193 |
+
|
| 194 |
+
#### Nanonets OCR2 Plus
|
| 195 |
+
<table style="border-collapse: collapse; width: 100%; font-family: Arial, sans-serif;">
|
| 196 |
+
<thead>
|
| 197 |
+
<tr>
|
| 198 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: left;">Model</th>
|
| 199 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: right;">Win Rate vs Nanonets OCR2 Plus (%)</th>
|
| 200 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: right;">Lose Rate vs Nanonets OCR2 Plus (%)</th>
|
| 201 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: right;">Both Correct (%)</th>
|
| 202 |
+
</tr>
|
| 203 |
+
</thead>
|
| 204 |
+
<tbody>
|
| 205 |
+
<tr>
|
| 206 |
+
<td style="border: 1px solid #ddd; padding: 8px;"><strong>Gemini 2.5 flash (No Thinking)</strong></td>
|
| 207 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">34.35</td>
|
| 208 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">57.60</td>
|
| 209 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">8.06</td>
|
| 210 |
+
</tr>
|
| 211 |
+
<tr>
|
| 212 |
+
<td style="border: 1px solid #ddd; padding: 8px;"><strong>Nanonets OCR2 3B</strong></td>
|
| 213 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">29.37</td>
|
| 214 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">54.58</td>
|
| 215 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">16.04</td>
|
| 216 |
+
</tr>
|
| 217 |
+
<tr>
|
| 218 |
+
<td style="border: 1px solid #ddd; padding: 8px;"><strong>Nanonets-OCR-s</strong></td>
|
| 219 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">24.86</td>
|
| 220 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">66.12</td>
|
| 221 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">9.02</td>
|
| 222 |
+
</tr>
|
| 223 |
+
<tr>
|
| 224 |
+
<td style="border: 1px solid #ddd; padding: 8px;"><strong>Nanonets OCR2 1.5B exp</strong></td>
|
| 225 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">13.00</td>
|
| 226 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">81.20</td>
|
| 227 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">5.79</td>
|
| 228 |
+
</tr>
|
| 229 |
+
<tr>
|
| 230 |
+
<td style="border: 1px solid #ddd; padding: 8px;"><strong>GPT-5 (Thinking: low)</strong></td>
|
| 231 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">23.53</td>
|
| 232 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">74.86</td>
|
| 233 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">1.60</td>
|
| 234 |
+
</tr>
|
| 235 |
+
</tbody>
|
| 236 |
+
</table>
|
| 237 |
+
|
| 238 |
+
#### Nanonets OCR2 3B
|
| 239 |
+
|
| 240 |
+
<table style="border-collapse: collapse; width: 100%; font-family: Arial, sans-serif;">
|
| 241 |
+
<thead>
|
| 242 |
+
<tr>
|
| 243 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: left;">Model</th>
|
| 244 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: right;">Win Rate vs Nanonets OCR2 3B (%)</th>
|
| 245 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: right;">Lose Rate vs Nanonets OCR2 3B (%)</th>
|
| 246 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: right;">Both Correct (%)</th>
|
| 247 |
+
</tr>
|
| 248 |
+
</thead>
|
| 249 |
+
<tbody>
|
| 250 |
+
<tr>
|
| 251 |
+
<td style="border: 1px solid #ddd; padding: 8px;"><strong>Gemini 2.5 flash (No Thinking)</strong></td>
|
| 252 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">39.98</td>
|
| 253 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">52.43</td>
|
| 254 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">7.58</td>
|
| 255 |
+
</tr>
|
| 256 |
+
<tr>
|
| 257 |
+
<td style="border: 1px solid #ddd; padding: 8px;"><strong>Nanonets-OCR-s</strong></td>
|
| 258 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">30.61</td>
|
| 259 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">58.28</td>
|
| 260 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">11.12</td>
|
| 261 |
+
</tr>
|
| 262 |
+
<tr>
|
| 263 |
+
<td style="border: 1px solid #ddd; padding: 8px;"><strong>Nanonets OCR2 1.5B exp</strong></td>
|
| 264 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">14.78</td>
|
| 265 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">79.18</td>
|
| 266 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">6.04</td>
|
| 267 |
+
</tr>
|
| 268 |
+
<tr>
|
| 269 |
+
<td style="border: 1px solid #ddd; padding: 8px;"><strong>GPT-5</strong></td>
|
| 270 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">25.00</td>
|
| 271 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">72.87</td>
|
| 272 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">2.13</td>
|
| 273 |
+
</tr>
|
| 274 |
+
</tbody>
|
| 275 |
+
</table>
|
| 276 |
+
|
| 277 |
+
### Visual Question Answering (VQA) Evaluations
|
| 278 |
+
<table style="border-collapse: collapse; width: 100%; font-family: Arial, sans-serif;">
|
| 279 |
+
<thead>
|
| 280 |
+
<tr>
|
| 281 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: left;">Dataset</th>
|
| 282 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: right;">Nanonets OCR2 Plus</th>
|
| 283 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: right;">Nanonets OCR2 3B</th>
|
| 284 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: right;">Qwen2.5-VL-72B-Instruct</th>
|
| 285 |
+
<th style="border: 1px solid #ddd; padding: 8px; text-align: right;">Gemini 2.5 Flash</th>
|
| 286 |
+
</tr>
|
| 287 |
+
</thead>
|
| 288 |
+
<tbody>
|
| 289 |
+
<tr>
|
| 290 |
+
<td style="border: 1px solid #ddd; padding: 8px;">ChartQA (IDP-Leaderboard)</td>
|
| 291 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">79.20</td>
|
| 292 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">78.56</td>
|
| 293 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">76.20</td>
|
| 294 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">84.82</td>
|
| 295 |
+
</tr>
|
| 296 |
+
<tr>
|
| 297 |
+
<td style="border: 1px solid #ddd; padding: 8px;">DocVQA (IDP-Leaderboard)</td>
|
| 298 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">85.15</td>
|
| 299 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">89.43</td>
|
| 300 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">84.00</td>
|
| 301 |
+
<td style="border: 1px solid #ddd; padding: 8px; text-align: right;">85.51</td>
|
| 302 |
+
</tr>
|
| 303 |
+
</tbody>
|
| 304 |
+
</table>
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
## Tips to improve accuracy
|
| 308 |
+
1. Increasing the image resolution will improve model's performance.
|
| 309 |
+
2. For complex tables (eg. Financial documents) using `repetition_penalty=1` gives better results. You can try this prompt also, which generally works better for finantial documents.
|
| 310 |
+
```python
|
| 311 |
+
user_prompt = """Extract the text from the above document as if you were reading it naturally. Return the tables in html format. Return the equations in LaTeX representation. If there is an image in the document and image caption is not present, add a small description of the image inside the <img></img> tag; otherwise, add the image caption inside <img></img>. Watermarks should be wrapped in brackets. Ex: <watermark>OFFICIAL COPY</watermark>. Page numbers should be wrapped in brackets. Ex: <page_number>14</page_number> or <page_number>9/22</page_number>. Prefer using ☐ and ☑ for check boxes."""
|
| 312 |
+
```
|
| 313 |
+
3. This is already implemented in [Docstrange](https://docstrange.nanonets.com/?output_type=markdown-financial-docs), please use the `Markdown (Financial Docs)` option for processing table heavy financial documents.
|
| 314 |
+
```python
|
| 315 |
+
import requests
|
| 316 |
+
|
| 317 |
+
url = "https://extraction-api.nanonets.com/extract"
|
| 318 |
+
headers = {"Authorization": <API KEY>}
|
| 319 |
+
|
| 320 |
+
files = {"file": open("/path/to/your/file", "rb")}
|
| 321 |
+
data = {"output_type": "markdown-financial-docs"}
|
| 322 |
+
|
| 323 |
+
response = requests.post(url, headers=headers, files=files, data=data)
|
| 324 |
+
print(response.json())
|
| 325 |
+
```
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
## BibTex
|
| 329 |
+
```
|
| 330 |
+
@misc{Nanonets-OCR2,
|
| 331 |
+
title={Nanonets-OCR2: A model for transforming documents into structured markdown with intelligent content recognition and semantic tagging},
|
| 332 |
+
author={Souvik Mandal and Ashish Talewar and Siddhant Thakuria and Paras Ahuja and Prathamesh Juvatkar},
|
| 333 |
+
year={2025},
|
| 334 |
+
}
|
| 335 |
+
```
|
| 336 |
+
|
| 337 |
+
<!--End Original Model Card-->
|
| 338 |
+
|
| 339 |
+
---
|
| 340 |
+
|
| 341 |
+
# <span id="testllm" style="color: #7F7FFF;">🚀 If you find these models useful</span>
|
| 342 |
+
|
| 343 |
+
Help me test my **AI-Powered Quantum Network Monitor Assistant** with **quantum-ready security checks**:
|
| 344 |
+
|
| 345 |
+
👉 [Quantum Network Monitor](https://readyforquantum.com/?assistant=open&utm_source=huggingface&utm_medium=referral&utm_campaign=huggingface_repo_readme)
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
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)
|
| 349 |
+
|
| 350 |
+
💬 **How to test**:
|
| 351 |
+
Choose an **AI assistant type**:
|
| 352 |
+
- `TurboLLM` (GPT-4.1-mini)
|
| 353 |
+
- `HugLLM` (Hugginface Open-source models)
|
| 354 |
+
- `TestLLM` (Experimental CPU-only)
|
| 355 |
+
|
| 356 |
+
### **What I’m Testing**
|
| 357 |
+
I’m pushing the limits of **small open-source models for AI network monitoring**, specifically:
|
| 358 |
+
- **Function calling** against live network services
|
| 359 |
+
- **How small can a model go** while still handling:
|
| 360 |
+
- Automated **Nmap security scans**
|
| 361 |
+
- **Quantum-readiness checks**
|
| 362 |
+
- **Network Monitoring tasks**
|
| 363 |
+
|
| 364 |
+
🟡 **TestLLM** – Current experimental model (llama.cpp on 2 CPU threads on huggingface docker space):
|
| 365 |
+
- ✅ **Zero-configuration setup**
|
| 366 |
+
- ⏳ 30s load time (slow inference but **no API costs**) . No token limited as the cost is low.
|
| 367 |
+
- 🔧 **Help wanted!** If you’re into **edge-device AI**, let’s collaborate!
|
| 368 |
+
|
| 369 |
+
### **Other Assistants**
|
| 370 |
+
🟢 **TurboLLM** – Uses **gpt-4.1-mini** :
|
| 371 |
+
- **It performs very well but unfortunatly OpenAI charges per token. For this reason tokens usage is limited.
|
| 372 |
+
- **Create custom cmd processors to run .net code on Quantum Network Monitor Agents**
|
| 373 |
+
- **Real-time network diagnostics and monitoring**
|
| 374 |
+
- **Security Audits**
|
| 375 |
+
- **Penetration testing** (Nmap/Metasploit)
|
| 376 |
+
|
| 377 |
+
🔵 **HugLLM** – Latest Open-source models:
|
| 378 |
+
- 🌐 Runs on Hugging Face Inference API. Performs pretty well using the lastest models hosted on Novita.
|
| 379 |
+
|
| 380 |
+
### 💡 **Example commands you could test**:
|
| 381 |
+
1. `"Give me info on my websites SSL certificate"`
|
| 382 |
+
2. `"Check if my server is using quantum safe encyption for communication"`
|
| 383 |
+
3. `"Run a comprehensive security audit on my server"`
|
| 384 |
+
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!
|
| 385 |
+
|
| 386 |
+
### Final Word
|
| 387 |
+
|
| 388 |
+
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.
|
| 389 |
+
|
| 390 |
+
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.
|
| 391 |
+
|
| 392 |
+
I'm also open to job opportunities or sponsorship.
|
| 393 |
+
|
| 394 |
+
Thank you! 😊
|