Guide · Open source
How to use DeepSeek-OCR: install, run and convert documents
Updated · written with AI from the project's own documentation and checked against our catalogue data
DeepSeek-OCR is an open research model from DeepSeek AI that reads text from images such as scanned pages or PDFs and converts it into text or markdown. This guide is for developers who want to run it themselves through Python. By the end you will know the setup the README expects, how to run inference with vLLM or Transformers, and which prompt to use for your task.
Quick start
- 1Clone the repository. Run git clone on the DeepSeek-OCR repo and enter its folder.
- 2Create the conda environment. Create an environment named deepseek-ocr with Python 3.12.9 and activate it.
- 3Install PyTorch for CUDA 11.8. Install torch 2.6.0, torchvision and torchaudio from the cu118 index.
- 4Install project requirements. Run pip install -r requirements.txt inside the repository folder.
- 5Pick a prompt and mode. Choose the prompt that matches your task, such as markdown conversion or Free OCR.
- 6Run the example script. Set your image path and output folder, then run run_dpsk_ocr.py or the Transformers snippet.
What DeepSeek-OCR is and who it suits
The project is released under the MIT licence and written in Python. The README frames it as an investigation into compressing text into visual tokens, using vision encoders from an LLM-centric viewpoint.
It fits developers who want an open-weight OCR model they can run on their own hardware, and teams converting scanned documents into markdown or plain text. It is less suited to people who want a point-and-click app, because the README only shows Python scripts and commands.
What you need before installing
The README says its environment is CUDA 11.8 with torch 2.6.0, and it uses Python 3.12.9 installed through conda. If you do not have an NVIDIA GPU with a CUDA setup, the install steps as written will not match your machine.
- Python 3.12.9 (created via conda, per the README)
- CUDA 11.8 with torch 2.6.0, per the README
- Conda
- An NVIDIA GPU environment
Install DeepSeek-OCR with conda and pip
Clone the repository, create and activate a conda environment, install the PyTorch build for CUDA 11.8, then install the project requirements from the repository folder.
- Clone the repo and enter the DeepSeek-OCR folder.
- Create and activate the conda environment.
- Install PyTorch (CUDA 11.8 build).
- Install the project requirements.
git clone https://github.com/deepseek-ai/DeepSeek-OCR.git
conda create -n deepseek-ocr python=3.12.9 -y && conda activate deepseek-ocr
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txtRun inference with Transformers
The Transformers example loads the model from the Hugging Face ID deepseek-ai/DeepSeek-OCR, moves it to the GPU in bfloat16, and calls model.infer on an image file. Set image_file to your own image and output_path to the folder where results should go.
The README also provides a ready script: change into DeepSeek-OCR-hf and run run_dpsk_ocr.py.
- Edit image_file and output_path in the example.
- Or run the script from the DeepSeek-OCR-hf folder.
cd DeepSeek-OCR-master/DeepSeek-OCR-hf
python run_dpsk_ocr.pyChoose a prompt for your task
The prompt decides what the model returns. The README lists examples for converting a document to markdown, OCR on a general image, plain text without layout, parsing figures and detailed image description.
- Document to markdown: <image>\n<|grounding|>Convert the document to markdown.
- Plain text without layouts: <image>\nFree OCR.
- Figures in a document: <image>\nParse the figure.
- General description: <image>\nDescribe this image in detail.
# document: <image>\n<|grounding|>Convert the document to markdown.
# without layouts: <image>\nFree OCR.Pick a resolution mode
The README lists four native resolution modes and one dynamic mode. Larger modes produce more vision tokens. The Transformers example uses base_size 1024, image_size 640 and crop_mode True.
- Tiny: 512×512 (64 vision tokens)
- Small: 640×640 (100 vision tokens)
- Base: 1024×1024 (256 vision tokens)
- Large: 1280×1280 (400 vision tokens)
- Gundam: dynamic resolution, n×640×640 plus 1×1024×1024
Use vLLM for faster batch work
The repository includes vLLM scripts for single images, PDFs and batch evaluation. Before running them, edit INPUT_PATH and OUTPUT_PATH in config.py inside DeepSeek-OCR-vllm. The README reports PDF concurrency of about 2500 tokens/s on an A100-40G, a single hardware figure rather than a general benchmark.
- run_dpsk_ocr_image.py: single image, streaming output
- run_dpsk_ocr_pdf.py: PDF processing
- run_dpsk_ocr_eval_batch.py: batch evaluation for benchmarks
cd DeepSeek-OCR-master/DeepSeek-OCR-vllm
python run_dpsk_ocr_image.pyWhat people use it for
- Converting scanned pages into markdown with the grounding prompt
- Extracting plain text from images with the Free OCR prompt
- Batch processing of PDFs with the vLLM scripts
- Researching visual-text compression with vision encoders
Frequently asked questions
Is DeepSeek-OCR free to use?
The repository is released under the MIT licence, according to the project metadata. The model weights are listed on Hugging Face under deepseek-ai/DeepSeek-OCR. Check the licence file in the repository for the full terms before commercial use.
What hardware do I need to run DeepSeek-OCR?
The README says its environment is CUDA 11.8 with torch 2.6.0, and the Transformers example calls .cuda(). An NVIDIA GPU with a CUDA setup is therefore the expected configuration. The README does not list minimum memory.
Can I use DeepSeek-OCR without writing Python?
Not from the README. It only shows Python scripts and commands, so you need to be comfortable running a conda environment and editing script settings.
How does DeepSeek-OCR compare to PaddleOCR, MinerU, GOT-OCR2.0 or Tesseract?
The README acknowledges PaddleOCR, MinerU and GOT-OCR2.0 as prior work and does not provide a head-to-head comparison. Tesseract is a separate, long-standing OCR engine. Test each on your own documents before choosing.
Why does my output have no layout or tags?
The prompt controls the output. Use the grounding markdown prompt for layout-aware markdown, or Free OCR for plain text without layouts, as listed in the README prompt examples.
Does DeepSeek-OCR guarantee accuracy on my documents?
No. The README shows examples but, in the text provided, does not give accuracy benchmarks. Run it on a sample of your own scans and check the results.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
DeepSeek-OCR suits developers and research teams who have an NVIDIA CUDA environment and want an open-weight OCR model they control. It is a poor fit for anyone who needs a graphical app or guaranteed accuracy on specific document types without testing, in which case tools like PaddleOCR, MinerU or Tesseract are worth comparing.
Install options & downloads