Skip to main content

Deepdoc

Installations

CPU-only (default):

pip install deepdoc-lib

GPU (Linux x86_64 only):

pip install deepdoc-lib[gpu]

Note: onnxruntime (CPU) and onnxruntime-gpu should not be installed together. If you're switching an existing environment to GPU, uninstall CPU ORT first:

pip uninstall -y onnxruntime
pip install onnxruntime-gpu==1.19.2

Parser Usage

from deepdoc import (
    DocxParser,
    ExcelParser,
    HtmlParser,
    PdfModelConfig,
    PdfParser,
    TokenizerConfig,
)

# Build configs
# Method 1: Explicit configuration (offline mode)
tokenizer_cfg = TokenizerConfig(
    offline=True,
    nltk_data_dir="/path/to/nltk_data",
)
pdf_model_cfg = PdfModelConfig(
    vision_model_dir="/path/to/models/vision",
    xgb_model_dir="/path/to/models/xgb",
    model_provider="local",
)

# Method 2: Empty configuration (auto-download models and nltk_data)
# tokenizer_cfg = TokenizerConfig()
# pdf_model_cfg = PdfModelConfig()


# Parse PDF
pdf_parser = PdfParser(model_cfg=pdf_model_cfg, tokenizer_cfg=tokenizer_cfg)
result = pdf_parser("document.pdf")

# Parse DOCX / HTML (tokenizer only)
docx_parser = DocxParser(tokenizer_cfg=tokenizer_cfg)
html_parser = HtmlParser(tokenizer_cfg=tokenizer_cfg)

# Parse Excel (no model/tokenizer dependency)
excel_parser = ExcelParser()
with open("data.xlsx", "rb") as f:
    result = excel_parser(f.read())

Or use explicit env factories:

tokenizer_cfg = TokenizerConfig.from_env()
pdf_model_cfg = PdfModelConfig.from_env()
pdf_parser = PdfParser(model_cfg=pdf_model_cfg, tokenizer_cfg=tokenizer_cfg)

Or rely on defaults (env + cache). Deepdoc will look for cached bundles under $DEEPDOC_MODEL_HOME (or ~/.cache/deepdoc) and only download missing files when the provider allows remote access:

pdf_parser = PdfParser()

env definitions:

# provider: auto | local | modelscope
export DEEPDOC_MODEL_PROVIDER=auto

# shared model cache root (default: ~/.cache/deepdoc)
export DEEPDOC_MODEL_HOME=/path/to/deepdoc-models

# optional bundle-specific local directories
export DEEPDOC_VISION_MODEL_DIR=/path/to/vision
export DEEPDOC_XGB_MODEL_DIR=/path/to/xgb

# single combined ModelScope repo (all bundles in one repo)
# (default: Xorbits/deepdoc)
export DEEPDOC_MODELSCOPE_REPO=Xorbits/deepdoc
# optional shared revision (default: master)
export DEEPDOC_MODELSCOPE_REVISION=master

# offline mode for tokenizer NLTK auto-download
export DEEPDOC_OFFLINE=0

# optional NLTK data controls for tokenizer
export DEEPDOC_NLTK_DATA_DIR=/path/to/nltk_data

Download model artifacts

To pre-download all model bundles (vision/xgb/tokenizer) into the default cache directory (~/.cache/deepdoc), run:

deepdoc-download-models
# or (from source checkout)
python -m deepdoc.download_models

If you want to override the cache location, set DEEPDOC_MODEL_HOME:

export DEEPDOC_MODEL_HOME=./models
deepdoc-download-models

By default this also downloads the required NLTK resources into ~/.cache/deepdoc/nltk_data (or $DEEPDOC_MODEL_HOME/nltk_data) and the cached cl100k_base tiktoken file into ~/.cache/deepdoc/tiktoken_cache (or $DEEPDOC_MODEL_HOME/tiktoken_cache). deepdoc.common.token_utils automatically points TIKTOKEN_CACHE_DIR at the same location unless you override it with DEEPDOC_TIKTOKEN_CACHE_DIR or TIKTOKEN_CACHE_DIR.

If you want to skip either optional offline asset, use:

deepdoc-download-models --no-nltk --no-tiktoken

Vision Model Usage

from deepdoc import create_vision_model
  • Use Environment Variable
# Vision model configs
export DEEPDOC_VISION_PROVIDER="qwen"
export DEEPDOC_VISION_API_KEY="your-api-key"
export DEEPDOC_VISION_MODEL="qwen-vl-max"
export DEEPDOC_VISION_LANG="Chinese"
export DEEPDOC_VISION_BASE_URL="http://your_base_url"

# Other configs
export DEEPDOC_LIGHTEN=0  # Whether to use lighten mode
vision_model = create_vision_model()
  • Use Default Provider
export DEEPDOC_VISION_API_KEY="your-api-key"
vision_model = create_vision_model("qwen")

Supported providers: ["openai", "qwen", "zhipu", "ollama", "gemini", "anthropic"]

  • Use Configuration File

Create deepdoc_config.yaml:

vision_model:
  provider: "qwen"
  model_name: "qwen-vl-max"
  api_key: "your-api-key"
  lang: "Chinese"
  base_url : "http://your-base-url"
vision_model = create_vision_model("/path/to/deepdoc_config.yaml")

Run

with open("image.jpg", "rb") as f:
    result = vision_model.describe_with_prompt(f.read())

Metadata

Release files for deepdoc-lib 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deepdoc-lib 0.2.2
File Size Uploaded
deepdoc_lib-0.2.2.tar.gz 4.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for deepdoc-lib 0.2.2
File Interpreter ABI Platform
deepdoc_lib-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 MB

Release files / deepdoc_lib-0.2.2.tar.gz

Download URL deepdoc_lib-0.2.2.tar.gz
Size 4.6 MB
Tags Source
SHA-256 checksum
How to use checksums
8bd43a238f6b67b95ff5dca92a4ff699ae72203de4e8989b4341c413f7b49329
BLAKE2b-256 checksum
How to use checksums
680e4a263228f5826dac97d250eb7cb9019bf4b0b2410d91605e2aeb145cfcb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Release files / deepdoc_lib-0.2.2-py3-none-any.whl

Download URL deepdoc_lib-0.2.2-py3-none-any.whl
Size 4.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
155d2312625b206c6cef2e34985a187f9901f2c30cb1a822ff05e4c03a4ac511
BLAKE2b-256 checksum
How to use checksums
f35bf901b403b68a1c8848c11ce7b488b0827deb8bd7edddfd83526e0518b1b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page