Text / Intermediate

Set up private chat with jina ocr v1

Run jinaai/jina-ocr-v1 locally as a document OCR model using Transformers with the custom model code from the Hugging Face snapshot. You will install the Python dependencies, load the model on a GPU if available (otherwise CPU), run OCR on a sample image, and confirm the model produced readable text.

EstimatedSource checked 9/25/2026
LOCALRENTED GPU

Before you begin

Difficulty
Intermediate
Software
Python 3, transformers, torch, torchvision, Pillow, Hugging Face Hub (for model download)
Hardware
This setup uses Transformers. The exact checkpoint format, context, and runtime overhead determine its memory need; a weight-file size alone is not a GPU recommendation.
TEXT / TRANSFORMERSSOURCE-LINKED SETUP

Set up private chat with jina ocr v1, step by step.

Run jinaai/jina-ocr-v1 locally as a document OCR model using Transformers with the custom model code from the Hugging Face snapshot. You will install the Python dependencies, load the model on a GPU if available (otherwise CPU), run OCR on a sample image, and confirm the model produced readable text.

Choose a package Run its commands Check the result
01
BEFORE YOU BEGIN

The documented package

This setup uses the package documented for this task. Review its source and supported platforms before starting.

The publisher has not provided a complete memory target for this task. Check its hardware guidance before starting.

CURRENT SETUP

jina ocr v1 · official

This setup uses Transformers. The exact checkpoint format, context, and runtime overhead determine its memory need; a weight-file size alone is not a GPU recommendation.

View weight source
02
THE WORKFLOW

Set up jina ocr v1 on your machine

Pick your operating system. Every command below is for the selected package and runtime.

The publisher supplies Python code but does not specify an operating system. Linux is a practical starting environment, not a publisher-tested machine. Run the Python snippets in one session, in order.

01

Install the Python dependencies

Install transformers, torch, torchvision, and Pillow in the Python environment you will use. These packages provide the AutoProcessor/AutoModelForCausalLM loading path and image loading used by the model's custom code.

02

Download jinaai/jina-ocr-v1 from Hugging Face

Load the model and processor from the official repository so the snapshot includes both the weights and the custom modeling code. Use trust_remote_code=True so the repository's own modeling files are used; there is no separate training or serving package to install.

03

Prepare an OCR image and run the model

Save a document page as document.png in your working directory. This script loads the model onto CUDA when available (otherwise CPU), prepares the OCR inputs, generates up to 4096 new tokens greedily, and decodes the OCR text. Keep the eos/pad settings from generation_config.json and do not pass a fresh GenerationConfig.

import torch from PIL import Image from transformers import AutoModelForCausalLM, AutoProcessor MODEL_ID = 'jinaai/jina-ocr-v1' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') processor = AutoProcessor.from_pretrained(MODEL_ID, trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained( MODEL_ID, dtype=torch.bfloat16, trust_remote_code=True, ).to(device) image = Image.open('document.png').convert('RGB') inputs = processor.prepare_ocr_inputs(image, device=device) output = model.generate(**inputs, max_new_tokens=4096, do_sample=False) print(processor.decode_ocr(output, inputs['input_ids']))
04

Confirm the model responded with OCR text

Look at the printed output of decode_ocr. It should contain text from document.png rather than an empty string or a repetition loop. For a chat-style first task, pass your own instruction through prepare_ocr_inputs, for example processor.prepare_ocr_inputs(image, prompt='Transcribe the provided document image into a clean Markdown format, preserving the natural reading order.', device=device), and check that the printed decoded output follows that instruction.

03
SUCCESS CHECK · jina ocr v1

Check the first local reply

Ask a short question with a known answer. Confirm the selected local model responds and verify the answer yourself before using it for private work.

This is a source-linked setup, not a YouRunAI hardware test. Confirm your exact runtime version, package, and output before relying on it.

Back to setup steps

When it doesn’t go to plan

The model output is empty or repeats the same text.

generate() attaches SlidingWindowNoRepeatNgramProcessor with no_repeat_ngram_size=35 and ngram_window=1024 by default. If the repetition whitelist causes issues with your document, override the keyword arguments in model.generate(...) with your own values, or disable the processor entirely with no_repeat_ngram_size=0.

Custom model code fails to load or imports are missing.

Ensure you installed transformers, torch, torchvision, and Pillow, and that you pass trust_remote_code=True to both AutoProcessor.from_pretrained and AutoModelForCausalLM.from_pretrained. The repository ships the custom code needed to load the weights.

Out of memory on a small GPU.

Load with a smaller dtype or run on CPU. The device is selected with torch.device('cuda' if torch.cuda.is_available() else 'cpu'); forcing CPU avoids GPU memory limits when the model cannot fit on the available device.

REFERENCE LIBRARY

Sources and files

Original instructions, model files, and compatibility notes behind this setup.

2 SOURCES

The model behind this workflow

jina ocr v1
MY HARDWARE

Will it run on your machine?

Save your machine to see a personalized rating and its reasoning.

Add my hardware

Keep exploring