DeepDoc Model Distribution#
DeepDoc's ONNX models and native dependency artifacts are pre-packaged into a dedicated ragflow_deps Docker image and downloaded at build time — not fetched lazily at runtime. Two separate download scripts serve two different distribution paths: one for baking artifacts into the full deps image, and one for the lightweight standalone DeepDoc OSS container. In embedded mode, the Recognizer base class will fall back to auto-downloading missing models from HuggingFace Hub at runtime.
Artifacts and Their Sources#
| Artifact | Source | Destination |
|---|---|---|
InfiniFlow/deepdoc ONNX models (layout.onnx, det.onnx, rec.onnx, tsr.onnx, ocr.res) | HuggingFace Hub | rag/res/deepdoc/ |
InfiniFlow/text_concat_xgb_v1.0 models | HuggingFace Hub | ragflow_deps/huggingface.co/ |
Apache Tika JAR (tika-server-standard-3.3.0.jar) | Maven Central / Huawei Cloud mirror | ragflow_deps/ |
NLTK data (wordnet, punkt, punkt_tab) | NLTK download | ragflow_deps/nltk_data/ |
libssl1.1 .deb packages (amd64 + arm64) | Ubuntu archive / Tsinghua mirror | ragflow_deps/ |
| Chrome for Testing + ChromeDriver 121 | Google Storage / npmmirror | ragflow_deps/ |
uv toolchain (x86_64 + aarch64) | GitHub Releases | ragflow_deps/ |
| Stagehand server binaries (x64 + arm64) | GitHub Releases | ragflow_deps/ |
Native Go libs: pdfium, pdf_oxide, office_oxide | GitHub Releases | ~/ragflow-native-libs/ |
tiktoken cl100k_base.tiktoken | OpenAI public blob | ragflow_deps/ |
Two Download Scripts#
ragflow_deps/download_deps.py — Full Deps Image#
ragflow_deps/download_deps.py downloads every artifact that the infiniflow/ragflow_deps Docker image bakes in. It must be run before building that image :
uv run ragflow_deps/download_deps.py [--china-mirrors]
cd ragflow_deps && docker build -f Dockerfile -t infiniflow/ragflow_deps .
The script anchors its CWD to its own directory so all outputs land under ragflow_deps/, matching the paths expected by ragflow_deps/Dockerfile .
It calls huggingface_hub.snapshot_download for two HuggingFace repos :
InfiniFlow/deepdocInfiniFlow/text_concat_xgb_v1.0
After downloading archives, it extracts the three native Go libraries (pdfium, pdf_oxide, office_oxide) into ~/ragflow-native-libs/ for use by build.sh during Go compilation . The --china-mirrors flag switches all download URLs to Tsinghua/Huawei Cloud/npmmirror alternatives .
deepdoc/server/download_deps.py — DeepDoc OSS Container#
deepdoc/server/download_deps.py is a minimal counterpart used only inside Dockerfile_deepdoc_oss. It downloads only the five ONNX files needed for standalone inference :
layout.onnx,det.onnx,rec.onnx,tsr.onnx,ocr.res
It respects the HF_ENDPOINT environment variable to redirect to https://hf-mirror.com for China builds, and skips files that already exist .
The ragflow_deps Image#
ragflow_deps/Dockerfile is built FROM scratch — it contains only the artifacts copied from the ragflow_deps/ directory after download_deps.py runs . The main Dockerfile mounts this image at build time via --mount=type=bind,from=infiniflow/ragflow_deps:latest,... to copy models, NLTK data, Tika, Chrome, and arch-specific binaries without any network access during the main image build .
DeepDoc OSS Container (Dockerfile_deepdoc_oss)#
Dockerfile_deepdoc_oss is a single-stage Ubuntu 24.04 image that:
- Installs
python3.12,onnxruntime,opencv-python-headless, and minimal dependencies via pip - Runs
deepdoc/server/download_deps.pyto pull the five ONNX models from HuggingFace into/app/rag/res/deepdoc - Runs
docker_stubs.pyto generate stub packages so vision modules load withouttorch,pdfplumber, or Ascend imports - Exposes port
9390and startsdeepdoc_server.py --model-dir /app/rag/res/deepdoc
Pass --build-arg NEED_MIRROR=1 to switch both pip and HuggingFace downloads to China-accessible mirrors .
China Mirror Support#
Both scripts and both Dockerfiles support NEED_MIRROR=1 / --china-mirrors:
| Location | Default | With mirror |
|---|---|---|
| HuggingFace | huggingface.co | hf-mirror.com (via HF_ENDPOINT) |
| PyPI | pypi.org | mirrors.aliyun.com/pypi/simple |
| Ubuntu debs | archive.ubuntu.com | mirrors.tuna.tsinghua.edu.cn |
| Maven (Tika) | repo1.maven.org | repo.huaweicloud.com |
| Chrome/ChromeDriver | Google Storage | registry.npmmirror.com |
Related Files#
| File | Role |
|---|---|
ragflow_deps/download_deps.py | Full artifact download for ragflow_deps image |
ragflow_deps/Dockerfile | Scratch image packaging all downloaded artifacts |
deepdoc/server/download_deps.py | ONNX-only download for standalone OSS container |
Dockerfile_deepdoc_oss | Standalone DeepDoc microservice image |
deepdoc/vision/recognizer.py | Base class; triggers runtime HF download if models absent |
build.sh | Uses ~/ragflow-native-libs/ extracted by download_deps.py |