PDF → OXR Markdown + layout JSON → instruction dataset → SFT LoRA → merge → GRPO LoRA → merge → evaluation.
python3 -m venv .venv
source .venv/bin/activate
pip install -e '.[dev]'
# Optional: pip install -e '.[quantization]'Ryze requires Python 3.10+, Gradio 6.x, Transformers 5.10–5.x, PyTorch 2.4+, Accelerate 1.1+, and PEFT 0.21.2+. GPU training requires a compatible PyTorch/CUDA installation. OXR runs in a separate service/environment: do not install its vLLM, Torch, or Transformers dependencies into Ryze's training environment. Tesseract is no longer used.
Follow the upstream local deployment instructions. The official Docker deployment includes the OXR recognition model, layout model, and document parsing API. Upstream recommends starting with a BF16-capable NVIDIA GPU and 24 GB VRAM; 48 GB or more is recommended for longer documents/concurrency. Download SoMarkAI/OXR-1.0, including its layout_analysis weights, before starting the service.
The Ryze URL must point to the document parsing API (http://127.0.0.1:8000/v1), not the recognition/layout model ports 8080/8081. Confirm the service independently:
curl --fail-with-body http://127.0.0.1:8000/v1/parse/sync \
-F 'file=@document.pdf' \
-F 'api_key=dummy' \
-F 'output_formats=markdown' \
-F 'output_formats=json'OXR can return parsing errors with HTTP 200. Ryze checks the API code, data.error, and required Markdown/JSON outputs before generating datasets. Timeouts, model failures, malformed responses, and empty Markdown fail the task rather than silently producing empty training data. There is no fallback OCR engine.
Edit configs/default_config_v2.json:
{
"data_processing": {
"ocr": {
"base_url": "http://127.0.0.1:8000/v1",
"api_key": "dummy",
"timeout": 300
},
"dataset": {"min_text_length": 50, "max_text_length": 2048},
"output_base": "./output"
}
}The snippet is the data section, not a replacement for all training settings. Old ocr.language, ocr.dpi, and ocr.use_gpu fields must be removed; they are rejected instead of silently ignored. OXR handles document languages and rendering server-side. timeout is the HTTP operation timeout in seconds; increase it for slow/long documents.
When fields are omitted, OXR_BASE_URL and OXR_API_KEY supply defaults. Explicit JSON/UI values take precedence. The shipped JSON explicitly selects the local service, so edit/remove those fields to use environment defaults. Do not commit production API keys.
python launch_app.py --config configs/default_config_v2.json --host 127.0.0.1
# Or: ./start.shOpen http://127.0.0.1:7860. In Data Processing, upload PDFs and set the OXR service URL/key/timeout. Results include:
markdown/<document>.md: OXR Markdown, with formulas, tables, code, and identifiers retained; images are disabled for this text-training pipeline.markdown/<document>.json: structured pages/blocks with layout coordinates.dataset/*_train.json,*_val.json,*_metadata.json: instruction samples and split metadata.processing_log.json: paths and parsing/dataset statistics.
Each processing run uses an isolated directory, including repeated processing of the same PDF. A one-sample dataset goes to training, with an empty validation split; empty datasets fail explicitly. Leave the validation path blank when no validation samples exist.
from ryze import RyzeConfig, RyzeDataProcessor
config = RyzeConfig.from_json("configs/default_config_v2.json")
processor = RyzeDataProcessor(config.data_processing.model_dump())
results = processor.process_batch(["document.pdf"])
for result in results:
if result["status"] != "success":
raise RuntimeError(result["error"])
print(result["dataset_result"]["train_path"])For the task API, build_default_pipeline(pdf_path, config=None) accepts the same RyzeConfig and propagates paths between stages. The UI also applies the data/training/evaluation sections of the selected config.
The default task pipeline isolates each document's data artifacts. When SFT auto_merge=False, it still materializes the complete SFT model required by GRPO; the final GRPO adapter can be evaluated without merging, provided its recorded base-model path remains available.
- Data Processing generates
instruction,input,outputrows. - SFT LoRA trains on response labels and saves an adapter; merge it into the base model before GRPO.
- GRPO LoRA trains on sampled completion tokens using group-relative rewards and a reference policy; merge the final adapter for inference.
- Evaluation uses a user-supplied benchmark. Missing benchmarks are errors; Ryze does not invent evaluation data.
Place a real benchmark at <evaluation.benchmarks_dir>/general_qa.json (the default task benchmark), with named splits:
{
"test": [
{
"id": "question-1",
"instruction": "Answer the question using the passage.",
"input": "Your document passage and question",
"expected_output": "Your curated reference answer"
}
]
}The example describes the file schema, not an evaluation dataset. For another benchmark name, create its corresponding JSON file and select it in the UI. Python compare_models() results under models are indexed by full supplied model paths, not basenames, so identically named directories remain distinct.
SFTDatasetGenerator currently uses instruction templates and rule-based extractive responses. It does not call Qwen/GPT/Claude or another QA-generation LLM. OXR replaces document parsing only; it is not a QA teacher or reward model. Review/curate generated targets before relying on training quality. Character-bounded chunking supports unspaced Chinese text, but does not guarantee semantic table/formula boundaries across chunks.
GRPO/PPO rewards remain heuristic length/diversity/word-overlap signals, not a learned reward model or ground-truth factuality metric. Preserving reference answers in the dataset does not mean they are used by the current reward function.
Local execution is supported. Cluster resource clients do not implement a remote training-task submission/result-transfer protocol. Distributed GPU task execution and the launcher's distributed UI mode fail explicitly rather than running training locally under a remote label.
The UI is a trusted, single-operator tool: it can read local paths, download models, write artifacts, and start expensive jobs. Use loopback binding; do not expose --share or a public bind to untrusted users without authentication and host-level isolation.
src/ryze/
data/ OXR API adapter, Markdown datasets, data orchestration
rl/ SFT, PPO, GRPO, LoRA, training datasets
eval/ metrics, benchmarks, evaluation
core/ task lifecycle, runners, pipeline DAG
cluster/ cluster resource clients
ui/ Gradio interfaces
configs/ runtime configurations
scripts/ Python example and training smoke command
ryze_demo/ static, simulated UI demo (not model inference)
demo/ optional Streamlit figure example
See CODE_REVIEW.md for prioritized findings, fixes, executed checks, and remaining deployment constraints.
pytest tests/unit/data tests/unit/test_config.py -qThese checks exercise the OXR response/failure contract with an isolated HTTP transport, dataset integrity, CJK chunk bounds, and configuration migration. They do not prove OXR recognition accuracy or GPU training quality. For real document acceptance, run the service above and process representative PDFs against a curated reference.
scripts/smoke_test_pipeline.py exercises SFT/GRPO with a small downloaded model; it uses synthetic Markdown and does not exercise OXR.
- Raised the Transformers security floor to 5.10.0 in both dependency manifests, addressing Dependabot alerts #1 (remote code execution), #2 (LightGlue model initialization code execution), and #3 (chat-template save path traversal). Aligned the PyTorch/Accelerate minimums with Transformers 5 and selected the validated PEFT version floor. Existing environments must run
pip install --upgrade -e '.[dev]'(orpip install --upgrade -r requirements.txt). - Validated with Transformers 5.10.0, PEFT 0.21.2, Accelerate 1.15.0, and CPU PyTorch 2.15.0: 85 training/evaluation unit tests passed; local tiny-model smoke checks covered full SFT, LoRA SFT, validation, checkpoint reload, and merged-model logit equivalence. CUDA and quantized training were not exercised.
- Replaced local Tesseract parsing with the OXR sync parsing API, preserving structured output and surfacing parsing failures.
- Removed destructive Markdown character stripping; bounded CJK chunks; prevented Markdown/dataset artifact collisions and empty training splits.
- Corrected response-label handling and sampled-token policy optimization in the trainers.
- Corrected pipeline failure propagation and evaluation isolation; removed false distributed execution and fabricated benchmark fallback behavior.
- Migrated UI controls/configuration and repaired the launcher/start script paths.
Ryze's repository LICENSE is GNU AGPL v3, not Apache 2.0.
OXR has a separate custom license, based on Apache 2.0 with additional terms. Under the current upstream terms, consolidated funding or annual revenue exceeding USD 2 million requires a separate commercial license for internal or external use; personal/noncommercial research is exempt from that threshold clause. Third-party services without a separate commercial license must prominently display “Powered by SoMark OXR” with the upstream link. Review the full license for your deployment.
Ryze defaults to a local service and never silently falls back to the public API. Only point the service URL at a host trusted to receive uploaded PDFs. The upstream FAQ states that free-API online data is used to improve OXR; do not send confidential documents there. The upstream free API also has no production availability guarantee.