AI SeedbankHelp preserve open and free AI for humanity's future

← All models

nanonets_Nanonets-OCR2-3B

nanonets · View on Hugging Face ↗

Get this model

Download TorrentMagnet Link

Seeders: · Leechers:

Model card

The complete upstream card, rendered from this payload's README.md — the same hash-verified bytes the torrent distributes. Images and off-site links are removed; the original card on Hugging Face carries them.


language:

  • multilingual base_model:
  • Qwen/Qwen2.5-VL-3B-Instruct tags:
  • OCR
  • image-to-text
  • pdf2markdown
  • VQA pipeline_tag: image-text-to-text library_name: transformers

Nanonets-OCR2: A model for transforming documents into structured markdown with intelligent content recognition and semantic tagging

🖥️ Live Demo | 📢 Blog | ⌨️ GitHub 📖 Cookbooks

Nanonets-OCR2 by Nanonets 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).

Nanonets-OCR2 is packed with features designed to handle complex documents with ease:

  • LaTeX Equation Recognition: Automatically converts mathematical equations and formulas into properly formatted LaTeX syntax. It distinguishes between inline ($...$) and display ($$...$$) equations.
  • 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.
  • 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.
  • Watermark Extraction: Detects and extracts watermark text from documents, placing it within a <watermark> tag.
  • Smart Checkbox Handling: Converts form checkboxes and radio buttons into standardized Unicode symbols (, , ) for consistent and reliable processing.
  • Complex Table Extraction: Accurately extracts complex tables from documents and converts them into both markdown and HTML table formats.
  • Flow charts & Organisational charts: Extracts flow charts and organisational as mermaid code.
  • Handwritten Documents: The model is trained on handwritten documents across multiple languages.
  • Multilingual: Model is trained on documents of multiple languages, including English, Chinese, French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Arabic, and many more.
  • 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."

Nanonets-OCR2 Family

Model Access Link
Nanonets-OCR2-Plus Docstrange link
Nanonets-OCR2-3B 🤗 link
Nanonets-OCR2-1.5B-exp 🤗 link

Usage

Using transformers

from PIL import Image
from transformers import AutoTokenizer, AutoProcessor, AutoModelForImageTextToText

model_path = "nanonets/Nanonets-OCR2-3B"

model = AutoModelForImageTextToText.from_pretrained(
    model_path, 
    torch_dtype="auto", 
    device_map="auto", 
    attn_implementation="flash_attention_2"
)
model.eval()

tokenizer = AutoTokenizer.from_pretrained(model_path)
processor = AutoProcessor.from_pretrained(model_path)


def ocr_page_with_nanonets_s(image_path, model, processor, max_new_tokens=4096):
    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."""
    image = Image.open(image_path)
    messages = [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": [
            {"type": "image", "image": f"file://{image_path}"},
            {"type": "text", "text": prompt},
        ]},
    ]
    text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
    inputs = processor(text=[text], images=[image], padding=True, return_tensors="pt")
    inputs = inputs.to(model.device)
    
    output_ids = model.generate(**inputs, max_new_tokens=max_new_tokens, do_sample=False)
    generated_ids = [output_ids[len(input_ids):] for input_ids, output_ids in zip(inputs.input_ids, output_ids)]
    
    output_text = processor.batch_decode(generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True)
    return output_text[0]

image_path = "/path/to/your/document.jpg"
result = ocr_page_with_nanonets_s(image_path, model, processor, max_new_tokens=15000)
print(result)

Using vLLM

  1. Start the vLLM server.
vllm serve nanonets/Nanonets-OCR2-3B
  1. Predict with the model
from openai import OpenAI
import base64

client = OpenAI(api_key="123", base_url="http://localhost:8000/v1")

model = "nanonets/Nanonets-OCR2-3B"

def encode_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")

def ocr_page_with_nanonets_s(img_base64):
    response = client.chat.completions.create(
        model=model,
        messages=[
            {
                "role": "user",
                "content": [
                    {
                        "type": "image_url",
                        "image_url": {"url": f"data:image/png;base64,{img_base64}"},
                    },
                    {
                        "type": "text",
                        "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.",
                    },
                ],
            }
        ],
        temperature=0.0,
        max_tokens=15000
    )
    return response.choices[0].message.content

test_img_path = "/path/to/your/document.jpg"
img_base64 = encode_image(test_img_path)
print(ocr_page_with_nanonets_s(img_base64))

Using Docstrange

import requests

url = "https://extraction-api.nanonets.com/extract"
headers = {"Authorization": <API KEY>}

files = {"file": open("/path/to/your/file", "rb")}
data = {"output_type": "markdown"}
data["model"] = "nanonets"

response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())

Check out Docstrange for more details.

Evaluation

Markdown Evaluations

Nanonets OCR2 Plus

Model Win Rate vs Nanonets OCR2 Plus (%) Lose Rate vs Nanonets OCR2 Plus (%) Both Correct (%)
Gemini 2.5 flash (No Thinking) 34.35 57.60 8.06
Nanonets OCR2 3B 29.37 54.58 16.04
Nanonets-OCR-s 24.86 66.12 9.02
Nanonets OCR2 1.5B exp 13.00 81.20 5.79
GPT-5 (Thinking: low) 23.53 74.86 1.60

Nanonets OCR2 3B

Model Win Rate vs Nanonets OCR2 3B (%) Lose Rate vs Nanonets OCR2 3B (%) Both Correct (%)
Gemini 2.5 flash (No Thinking) 39.98 52.43 7.58
Nanonets-OCR-s 30.61 58.28 11.12
Nanonets OCR2 1.5B exp 14.78 79.18 6.04
GPT-5 25.00 72.87 2.13

Visual Question Answering (VQA) Evaluations

Dataset Nanonets OCR2 Plus Nanonets OCR2 3B Qwen2.5-VL-72B-Instruct Gemini 2.5 Flash
ChartQA (IDP-Leaderboard) 79.20 78.56 76.20 84.82
DocVQA (IDP-Leaderboard) 85.15 89.43 84.00 85.51

Tips to improve accuracy

  1. Increasing the image resolution will improve model's performance.
  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.
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. Only return HTML table within <table></table>."""
  1. This is already implemented in Docstrange, please use the Markdown (Financial Docs) option for processing table heavy financial documents.
import requests

url = "https://extraction-api.nanonets.com/extract"
headers = {"Authorization": <API KEY>}

files = {"file": open("/path/to/your/file", "rb")}
data = {"output_type": "markdown-financial-docs"}

response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())
  1. Model might work best on certain resolution for specific document types. Please check the cookbooks for details.

BibTex

@misc{Nanonets-OCR2,
  title={Nanonets-OCR2: A model for transforming documents into structured markdown with intelligent content recognition and semantic tagging},
  author={Souvik Mandal and Ashish Talewar and Siddhant Thakuria and Paras Ahuja and Prathamesh Juvatkar},
  year={2025},
}

Magnet link

Opens the swarm directly in your torrent client — no file download needed. Copy-paste works too:

magnet:?xt=urn:btih:a994619f85dd62a0943e53a90f2cbc9a673c269b&dn=nanonets_Nanonets-OCR2-3B

Open magnet in torrent client · infohash a994619f85dd62a0943e53a90f2cbc9a673c269b

Files & hashes

PathSizesha1sha256
Modelfile424 B (424 B)3e538e38b4012e0fe6423916f29f8c7efa2fc5d095d2a815e542d15e9f7a4feeab46402d7f8cef3b63ba3c26a5c4d9f6e70f8e9f
README.md15.7 KB (16,053 B)320f2b0f3239b24e930cd2fede0f618eee64d0b5b014575f22c2509b8ca793a12124d747f32d4199d95a3044acb37ea91e9dafe1
added_tokens.json605 B (605 B)482ced4679301bf287ebb310bdd1790eb451423258b54bbe36fc752f79a24a271ef66a0a0830054b4dfad94bde757d851968060b
chat_template.jinja1017 B (1,017 B)6c226632394ae7474b0d4b13e15793eac2e21ee9a0bc6f6fc7a29a80017a433e8f03a1cc1236e838a944a2d034295a60c4f2fddb
config.json3.3 KB (3,412 B)f825483a1bea794e8dcec09de5581b627eae5fc6bf7746bb1587334e56b59e4af068e6ed9fe389476670699365be76ba524bf696
generation_config.json214 B (214 B)8eaa32b1827f8998119914807ce68733b5f84205f0946902da9a52ef1b646efaa4510ed960e6b6a47619e644ce549ac28a1e041d
merges.txt1.6 MB (1,671,853 B)31349551d90c7606f325fe0f11bbb8bd5fa0d7c78831e4f1a044471340f7c0a83d7bd71306a5b867e95fd870f74d0c5308a904d5
model-00001-of-00002.safetensors4.65 GB (4,997,750,760 B)02e49b34446a12e244bf49f22a48959d8784ec0e84c3306e843b6399d68fa73dce66d34c3b1c68e379741b7a5c6bddb615fc5dcd
model-00002-of-00002.safetensors2.34 GB (2,511,587,184 B)8b8e54a95d26c5fcfbf693f13efe5f09dc176d388002ad9c8c624a7d1295c09b1d3ff571920f72ee66b0bb308931db62fa2e81ce
model.safetensors.index.json63.9 KB (65,484 B)cdd15139a5804800457356edcdde2dcb975c5b023926d103f74c183f387097ac4d00e7fff7dae7cd0ab24427f585b84c6feea9d6
preprocessor_config.json791 B (791 B)849f287996c2384a75917336bd4c4bdd28b73b35276e1dbe46dd567fce6e587665266ede535f42ab08d46f3d7febea17cb37abcd
special_tokens_map.json613 B (613 B)ac23c0aaa2434523c494330aeb79c5839537810376862e765266b85aa9459767e33cbaf13970f327a0e88d1c65846c2ddd3a1ecd
tokenizer.json10.9 MB (11,421,896 B)dff01364e9c19e8476160c3f079e58f1d85900e19c5ae00e602b8860cbd784ba82a8aa14e8feecec692e7076590d014d7b7fdafa
tokenizer_config.json4.6 KB (4,756 B)04c90184b692d77b8af360ee05e889fb5e4c88568160131af9f1a4b44ace4fb7a707d6315f90efa6bcb4828a82972dfafed6a458
video_preprocessor_config.json907 B (907 B)6662e15042913e44162efcece6ee3bd643ffbcf109e98526bcd1b8584217418253badf2824ecf2815933b0583cdceb2e8f79ebb0
vocab.json2.6 MB (2,776,833 B)4783fe10ac3adce15ac8f358ef5462739852c569ca10d7e9fb3ed18575dd1e277a2579c16d108e32f27439684afa0e10b1440910

Cite this release

Canonical URL
https://aiseedbank.org/models/nanonets_Nanonets-OCR2-3B/
Slug
nanonets_Nanonets-OCR2-3B
Infohash
a994619f85dd62a0943e53a90f2cbc9a673c269b
License
no license recorded
Signing key fingerprint
85a3b32c3712427b

Every file carries a locally computed sha256 — verify a download against the signed sums: nanonets_Nanonets-OCR2-3B.SHA256SUMS (+ minisign signature).

Provenance

Upstream repositorynanonets/Nanonets-OCR2-3B
Revision (pinned)c3886ff00bb037ce7da24988c9eafaf1fe2bed72
Fetched at2026-09-04T03:15:34Z
License at fetchno license recorded
Snapshot toolhuggingface · seedbank 0.1.0

Trackers

✓ verified · rehash-vs-hf-metadata at 2026-09-04T03:16:44Z

no license recorded7.01 GB (7,525,302,802 bytes)transformerssafetensorsqwen2_5_vlimage-text-to-textOCRimage-to-textpdf2markdownVQAconversationalmultilingualeval-resultstext-generation-inferenceendpoints_compatible