Downloads · 30 days
0
mohameddalii/ocr-mt-asr-5090
ocr-mt-asr-5090 is a translation model from mohameddalii. Use it when you need text moved from one language to another. It is set up for vllm. The card lists the license as apache-2.0.
Serve kit for three colocated vLLM processes plus a FastAPI gateway with Swagger. This repo is scripts + engines, not a weight dump — vLLM still pulls the official model repos.
Downloads · 30 days
0
Access
Public
Updated Sep 15, 2026
Repo size
933 KB
Likes
0
Public
Click a slice to open those files.
.ttf933 KB · 86%
From the Hugging Face model README
Serve kit for three colocated vLLM processes plus a FastAPI gateway with Swagger. This repo is scripts + engines, not a weight dump — vLLM still pulls the official model repos.
Proven together on a Vast.ai 5090 (bf16, no quantization):
| Service | GPU share | Context | Parallel seqs | Notes |
|---|---|---|---|---|
Qwen3-MT (Qwen/Qwen3-4B-Instruct-2507) | 0.36 (~11.4 GB) | 2048 | 8 | prefix cache, aliases Qwen3-4B / Qwen/Qwen3-4B |
| PaddleOCR-VL | 0.38 (~12.2 GB) | 8192 | 8 | OCR: prompt, layout crops |
| Cohere Transcribe Arabic | 0.16 (~5.5 GB) | 128 | 128 | /v1/audio/transcriptions |
| Inference API (gateway) | CPU | — | — | Swagger /docs |
Start Qwen first, then OCR, then Cohere. Utils sum to 0.90 so the 32 GB card does not OOM. Do not raise both MT and OCR so they sum past ~0.90 with ASR. Do not switch to 4-bit.
hf download mohameddalii/ocr-mt-asr-5090 --local-dir ./ocr-mt-asr-5090
cd ocr-mt-asr-5090
python3 -m venv .venv && source .venv/bin/activate
uv pip install -r requirements.txt
# Blackwell: if CUDA tensors fail, reinstall torch with cu128+
# uv pip install torch --index-url https://download.pytorch.org/whl/cu128
uv pip install librosa soundfile # Cohere audio
bash scripts/prefetch.sh # optional, caches the three models
bash scripts/serve_three.sh # MT → OCR → ASR
python3 python/doc_api.py # gateway on 127.0.0.1:18000
Internal binds:
| Process | Port |
|---|---|
| Qwen3-MT | 127.0.0.1:8091 |
| PaddleOCR-VL | 127.0.0.1:8092 |
| Cohere ASR | 127.0.0.1:8093 |
| Gateway + Swagger | 127.0.0.1:18000/docs |
python python/translate.py --from English --to Arabic "The total is 12 dollars."
python python/ocr.py scan.png
python python/ingest.py invoice.pdf --json
Need three free normal ports at instance create time (defaults 10100, 10200, 3000) plus the image’s existing 8000 for the gateway.
cd /workspace
hf download mohameddalii/ocr-mt-asr-5090 --local-dir /workspace/ocr-mt-asr-5090
bash /workspace/ocr-mt-asr-5090/vast/install_vast.sh
That copies supervisor wrappers, adds portal entries, starts MT → OCR → ASR, then the gateway.
A Cloudflare quick tunnel (*.trycloudflare.com) is started in front of the gateway so the browser padlock is a real public CA. The Vast IP HTTPS cert is self-signed (jupyter.vast.ai) — do not use it from the backend.
Public URLs: vast-capabilities direct_url for raw models (optional), gateway Swagger via the tunnel printed in /var/log/portal/gateway-tunnel.log.
Needed fields only. Files are binary. target_lang is an ISO 639-1 id (ar, en, fr) — not "Arabic".
| Endpoint | Send | Return |
|---|---|---|
POST /ingest | multipart file (any type); optional target_lang | {"text","lang","language","kind","method","char_count"} |
POST /translate | JSON content + target_lang | {"text": "...", "lang": "en"} |
POST /ocr | multipart image | {"text": "...", "lang": "en"} |
POST /transcribe | multipart file (mp3/mp4/wav/…) | {"transcript": "...", "lang": "ar"} |
POST /detect | multipart file | {"lang": "ar"} |
POST /file2text | multipart file + target_lang | translated file (pdf/docx/xlsx/txt), original layout, words wrap inside the page frame |
GET /health | — | {"ok": true} |
GET /status | — | which of the three models are up |
GET /docs | — | Swagger UI |
GET /backend-guide.pdf | — | backend contract PDF |
curl -sS https://<gateway>/ingest -F [email protected]
# {"text": "...", "lang": "en", "language": "English", "kind": "pdf", ...}
curl -sS https://<gateway>/translate \
-H 'Content-Type: application/json' \
-d '{"content":"The total is 12 dollars.","target_lang":"ar"}'
# {"text": "المجموع هو 12 دولارًا.", "lang": "en"}
| Variable | Default | Role |
|---|---|---|
MT_GPU_UTIL | 0.36 | Qwen GPU fraction |
OCR_GPU_UTIL | 0.38 | OCR GPU fraction |
ASR_GPU_UTIL | 0.16 | Cohere GPU fraction |
MT_PORT / OCR_PORT / ASR_PORT | 8091 / 8092 / 8093 | bind ports |
DOC_API_PORT | 18000 | gateway |
HF_HOME | ./.hf_home | model cache |
VENV / MT_VENV / OCR_VENV / ASR_VENV | .venv | python env |
/file2text: keeps the original PDF/DOCX/XLSX/PPTX structure. Article PDFs reflow so words wrap at spaces and stay inside the page margins (no mid-word clip at the right edge). Arabic uses Noto Naskh + HarfBuzz./transcribe: ffmpeg → 16 kHz mono WAV, then 30s chunks. Optional Form language (ar / en). Silence-only chunks are skipped; @@فراغ is stripped./ocr: full-page only. CJK is stripped unless the page is actually Chinese./translate: chunks long text so it fits Qwen’s 2048 context.scripts/serve_three.sh start all three (MT first)
scripts/serve_mt.sh
scripts/serve_ocr.sh
scripts/serve_asr.sh
scripts/prefetch.sh
python/doc_api.py FastAPI gateway + Swagger
python/layout_export.py file2text overlay / reflow
python/ocr_engine.py full-page OCR + CJK filter
python/mt_engine.py glossary + copy-spans + 2048-safe chunks
python/ingest.py any file → text + language + ASR chunks
python/ocr.py / translate.py
fonts/ Noto Naskh Arabic + DejaVu Sans
vast/install_vast.sh supervisor + portal + CF tunnel
Weights: Qwen/Qwen3-4B-Instruct-2507, PaddlePaddle/PaddleOCR-VL, CohereLabs/cohere-transcribe-arabic-07-2026. Two-model-only kit (no ASR/gateway): mohameddalii/ocr-mt-5090.