Skip to main content

Deepdoc

Installations

CPU-only (default):

pip install deepdoc-lib

GPU (Linux x86_64 only):

pip install deepdoc-lib[gpu]

Gemini vision provider (optional, installs the google-genai SDK):

pip install deepdoc-lib[gemini]

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"]

The gemini provider needs the gemini extra: pip install deepdoc-lib[gemini].

  • 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.5

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.5
File Size Uploaded Provenance Actions
deepdoc_lib-0.2.5.tar.gz 4.7 MB With provenance Details for deepdoc_lib-0.2.5.tar.gz

Built distribution (wheel)

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

Total release size: 9.3 MB

Release files / deepdoc_lib-0.2.5.tar.gz

Download URL deepdoc_lib-0.2.5.tar.gz
Size 4.7 MB
Tags Source
SHA-256 checksum
How to use checksums
1f7ba788ff0566fbd9cdbe14945589fa72424cf82398fb5797beb7acb852376a
BLAKE2b-256 checksum
How to use checksums
362ee3593e2f61071d22190370b4323c722acf2d1e792c9d32bda7656cade156
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 9, 2026.

Transparency log

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

Download URL deepdoc_lib-0.2.5-py3-none-any.whl
Size 4.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
ccb6587dab899a229017939a070fbb7b2334781bd7b52fefc3843a0252351e16
BLAKE2b-256 checksum
How to use checksums
c2cfe6e8ed72d1e4cec4f22e59ad03295d07d96089d1506962888a8fca89c2ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 9, 2026.

Transparency log

Security for deepdoc-lib 0.2.5

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for deepdoc_lib-0.2.5.tar.gz

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 Nov 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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