📝 Enhanced model card with GT-REX variants (Nano/Pro/Ultra), benchmarks, and usage guide
Browse files
README.md
CHANGED
|
@@ -12,89 +12,170 @@ tags:
|
|
| 12 |
- text-extraction
|
| 13 |
- invoice-processing
|
| 14 |
- production
|
|
|
|
|
|
|
| 15 |
pipeline_tag: image-text-to-text
|
|
|
|
|
|
|
|
|
|
| 16 |
---
|
| 17 |
|
| 18 |
# GT-REX-v4: Production OCR Model
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
## ⚙️ GT-REX Variants
|
| 23 |
|
| 24 |
-
GT-REX-v4
|
| 25 |
|
| 26 |
| Variant | Speed | Accuracy | Resolution | GPU Memory | Throughput | Best For |
|
| 27 |
|---------|-------|----------|------------|------------|------------|----------|
|
| 28 |
-
| **🚀 Nano** | ⚡⚡⚡⚡⚡ | ⭐⭐⭐ | 640px | 4
|
| 29 |
-
| **⚡ Pro** | ⚡⚡⚡⚡ | ⭐⭐⭐⭐ | 1024px | 6
|
| 30 |
-
| **🎯 Ultra** | ⚡⚡⚡ | ⭐⭐⭐⭐⭐ | 1536px | 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
### 🚀 GT-Rex-Nano
|
|
|
|
| 33 |
**Speed-optimized for high-volume batch processing**
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
```python
|
|
|
|
|
|
|
| 41 |
llm = LLM(
|
| 42 |
-
model=
|
| 43 |
trust_remote_code=True,
|
| 44 |
max_model_len=2048,
|
| 45 |
gpu_memory_utilization=0.6,
|
| 46 |
max_num_seqs=256,
|
| 47 |
-
|
| 48 |
)
|
| 49 |
```
|
| 50 |
|
|
|
|
|
|
|
| 51 |
### ⚡ GT-Rex-Pro (Default)
|
| 52 |
-
**Balanced quality and speed for standard documents**
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
```python
|
|
|
|
|
|
|
| 60 |
llm = LLM(
|
| 61 |
-
model=
|
| 62 |
trust_remote_code=True,
|
| 63 |
max_model_len=4096,
|
| 64 |
gpu_memory_utilization=0.75,
|
| 65 |
max_num_seqs=128,
|
| 66 |
-
|
| 67 |
)
|
| 68 |
```
|
| 69 |
|
|
|
|
|
|
|
| 70 |
### 🎯 GT-Rex-Ultra
|
| 71 |
-
**Maximum quality with adaptive processing**
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
```python
|
|
|
|
|
|
|
| 79 |
llm = LLM(
|
| 80 |
-
model=
|
| 81 |
trust_remote_code=True,
|
| 82 |
max_model_len=8192,
|
| 83 |
gpu_memory_utilization=0.85,
|
| 84 |
max_num_seqs=64,
|
| 85 |
-
|
| 86 |
)
|
| 87 |
```
|
| 88 |
|
|
|
|
|
|
|
| 89 |
## 🎯 Key Features
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
## 📊 Model Details
|
| 100 |
|
|
@@ -106,18 +187,338 @@ llm = LLM(
|
|
| 106 |
| **Parameters** | ~7B |
|
| 107 |
| **License** | MIT |
|
| 108 |
| **Release Date** | February 2026 |
|
| 109 |
-
| **Precision** | BF16/FP16 |
|
| 110 |
-
| **Input Resolution** | 640px
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
## 💻 Installation
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
```bash
|
| 117 |
pip install vllm pillow torch transformers
|
| 118 |
```
|
| 119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
---
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
- text-extraction
|
| 13 |
- invoice-processing
|
| 14 |
- production
|
| 15 |
+
- handwriting-recognition
|
| 16 |
+
- table-extraction
|
| 17 |
pipeline_tag: image-text-to-text
|
| 18 |
+
model-index:
|
| 19 |
+
- name: GT-REX-v4
|
| 20 |
+
results: []
|
| 21 |
---
|
| 22 |
|
| 23 |
# GT-REX-v4: Production OCR Model
|
| 24 |
|
| 25 |
+
<p align="center">
|
| 26 |
+
<strong>🦖 GothiTech Recognition & Extraction eXpert — Version 4</strong>
|
| 27 |
+
</p>
|
| 28 |
+
|
| 29 |
+
<p align="center">
|
| 30 |
+
<a href="https://huggingface.co/developerJenis/GT-REX-v4"><img src="https://img.shields.io/badge/🤗_Model-GT--REX--v4-blue" alt="Model"></a>
|
| 31 |
+
<a href="#"><img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License: MIT"></a>
|
| 32 |
+
<a href="#"><img src="https://img.shields.io/badge/vLLM-Supported-orange" alt="vLLM"></a>
|
| 33 |
+
<a href="#"><img src="https://img.shields.io/badge/Params-~7B-red" alt="Parameters"></a>
|
| 34 |
+
</p>
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
**GT-REX-v4** is a state-of-the-art production-grade OCR model developed by **GothiTech** for enterprise document understanding, text extraction, and intelligent document processing. Built on a Vision-Language Model (VLM) architecture, it delivers high-accuracy text extraction from complex documents including invoices, contracts, forms, handwritten notes, and dense tables.
|
| 39 |
+
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
## 📑 Table of Contents
|
| 43 |
+
|
| 44 |
+
- [GT-REX Variants](#-gt-rex-variants)
|
| 45 |
+
- [Key Features](#-key-features)
|
| 46 |
+
- [Model Details](#-model-details)
|
| 47 |
+
- [Quick Start](#-quick-start)
|
| 48 |
+
- [Installation](#-installation)
|
| 49 |
+
- [Usage Examples](#-usage-examples)
|
| 50 |
+
- [Use Cases](#-use-cases)
|
| 51 |
+
- [Performance Benchmarks](#-performance-benchmarks)
|
| 52 |
+
- [Prompt Engineering Guide](#-prompt-engineering-guide)
|
| 53 |
+
- [API Integration](#-api-integration)
|
| 54 |
+
- [Troubleshooting](#-troubleshooting)
|
| 55 |
+
- [License](#-license)
|
| 56 |
+
- [Citation](#-citation)
|
| 57 |
+
|
| 58 |
+
---
|
| 59 |
|
| 60 |
## ⚙️ GT-REX Variants
|
| 61 |
|
| 62 |
+
GT-REX-v4 ships with **three optimized configurations** tailored to different performance and accuracy requirements. All variants share the same underlying model weights — they differ only in inference settings.
|
| 63 |
|
| 64 |
| Variant | Speed | Accuracy | Resolution | GPU Memory | Throughput | Best For |
|
| 65 |
|---------|-------|----------|------------|------------|------------|----------|
|
| 66 |
+
| **🚀 Nano** | ⚡⚡⚡⚡⚡ | ⭐⭐⭐ | 640px | 4–6 GB | 100–150 docs/min | High-volume batch processing |
|
| 67 |
+
| **⚡ Pro** *(Default)* | ⚡⚡⚡⚡ | ⭐⭐⭐⭐ | 1024px | 6–10 GB | 50–80 docs/min | Standard enterprise workflows |
|
| 68 |
+
| **🎯 Ultra** | ⚡⚡⚡ | ⭐⭐⭐⭐⭐ | 1536px | 10–15 GB | 20–30 docs/min | High-accuracy & fine-detail needs |
|
| 69 |
+
|
| 70 |
+
### How to Choose a Variant
|
| 71 |
+
|
| 72 |
+
- **Nano** → You need maximum throughput and documents are simple (receipts, IDs, labels).
|
| 73 |
+
- **Pro** → General-purpose. Best balance for invoices, contracts, forms, and reports.
|
| 74 |
+
- **Ultra** → Documents have fine print, dense tables, medical records, or legal footnotes.
|
| 75 |
+
|
| 76 |
+
---
|
| 77 |
|
| 78 |
### 🚀 GT-Rex-Nano
|
| 79 |
+
|
| 80 |
**Speed-optimized for high-volume batch processing**
|
| 81 |
|
| 82 |
+
| Setting | Value |
|
| 83 |
+
|---------|-------|
|
| 84 |
+
| Resolution | 640 × 640 px |
|
| 85 |
+
| Speed | ~1–2s per image |
|
| 86 |
+
| Max Tokens | 2048 |
|
| 87 |
+
| GPU Memory | 4–6 GB |
|
| 88 |
+
| Recommended Batch Size | 256 sequences |
|
| 89 |
+
|
| 90 |
+
**Best for:** Thumbnails, previews, high-throughput pipelines (100+ docs/min), mobile uploads, receipt scanning.
|
| 91 |
|
| 92 |
```python
|
| 93 |
+
from vllm import LLM
|
| 94 |
+
|
| 95 |
llm = LLM(
|
| 96 |
+
model="developerJenis/GT-REX-v4",
|
| 97 |
trust_remote_code=True,
|
| 98 |
max_model_len=2048,
|
| 99 |
gpu_memory_utilization=0.6,
|
| 100 |
max_num_seqs=256,
|
| 101 |
+
limit_mm_per_prompt={"image": 1},
|
| 102 |
)
|
| 103 |
```
|
| 104 |
|
| 105 |
+
---
|
| 106 |
+
|
| 107 |
### ⚡ GT-Rex-Pro (Default)
|
|
|
|
| 108 |
|
| 109 |
+
**Balanced quality and speed for standard enterprise documents**
|
| 110 |
+
|
| 111 |
+
| Setting | Value |
|
| 112 |
+
|---------|-------|
|
| 113 |
+
| Resolution | 1024 × 1024 px |
|
| 114 |
+
| Speed | ~2–5s per image |
|
| 115 |
+
| Max Tokens | 4096 |
|
| 116 |
+
| GPU Memory | 6–10 GB |
|
| 117 |
+
| Recommended Batch Size | 128 sequences |
|
| 118 |
+
|
| 119 |
+
**Best for:** Contracts, forms, invoices, reports, government documents, insurance claims.
|
| 120 |
|
| 121 |
```python
|
| 122 |
+
from vllm import LLM
|
| 123 |
+
|
| 124 |
llm = LLM(
|
| 125 |
+
model="developerJenis/GT-REX-v4",
|
| 126 |
trust_remote_code=True,
|
| 127 |
max_model_len=4096,
|
| 128 |
gpu_memory_utilization=0.75,
|
| 129 |
max_num_seqs=128,
|
| 130 |
+
limit_mm_per_prompt={"image": 1},
|
| 131 |
)
|
| 132 |
```
|
| 133 |
|
| 134 |
+
---
|
| 135 |
+
|
| 136 |
### 🎯 GT-Rex-Ultra
|
|
|
|
| 137 |
|
| 138 |
+
**Maximum quality with adaptive processing for complex documents**
|
| 139 |
+
|
| 140 |
+
| Setting | Value |
|
| 141 |
+
|---------|-------|
|
| 142 |
+
| Resolution | 1536 × 1536 px |
|
| 143 |
+
| Speed | ~5–10s per image |
|
| 144 |
+
| Max Tokens | 8192 |
|
| 145 |
+
| GPU Memory | 10–15 GB |
|
| 146 |
+
| Recommended Batch Size | 64 sequences |
|
| 147 |
+
|
| 148 |
+
**Best for:** Legal documents, fine print, dense tables, medical records, engineering drawings, academic papers, multi-column layouts.
|
| 149 |
|
| 150 |
```python
|
| 151 |
+
from vllm import LLM
|
| 152 |
+
|
| 153 |
llm = LLM(
|
| 154 |
+
model="developerJenis/GT-REX-v4",
|
| 155 |
trust_remote_code=True,
|
| 156 |
max_model_len=8192,
|
| 157 |
gpu_memory_utilization=0.85,
|
| 158 |
max_num_seqs=64,
|
| 159 |
+
limit_mm_per_prompt={"image": 1},
|
| 160 |
)
|
| 161 |
```
|
| 162 |
|
| 163 |
+
---
|
| 164 |
+
|
| 165 |
## 🎯 Key Features
|
| 166 |
|
| 167 |
+
| Feature | Description |
|
| 168 |
+
|---------|-------------|
|
| 169 |
+
| **High Accuracy** | Advanced vision-language architecture for precise text extraction |
|
| 170 |
+
| **Multi-Language** | Handles documents in English and multiple other languages |
|
| 171 |
+
| **Production Ready** | Optimized for deployment with the vLLM inference engine |
|
| 172 |
+
| **Batch Processing** | Process hundreds of documents per minute (Nano variant) |
|
| 173 |
+
| **Flexible Prompts** | Supports structured extraction — JSON, tables, key-value pairs, forms |
|
| 174 |
+
| **Handwriting Support** | Transcribes handwritten text with high fidelity |
|
| 175 |
+
| **Three Variants** | Nano (speed), Pro (balanced), Ultra (accuracy) |
|
| 176 |
+
| **Structured Output** | Extract data directly into JSON, Markdown tables, or custom schemas |
|
| 177 |
+
|
| 178 |
+
---
|
| 179 |
|
| 180 |
## 📊 Model Details
|
| 181 |
|
|
|
|
| 187 |
| **Parameters** | ~7B |
|
| 188 |
| **License** | MIT |
|
| 189 |
| **Release Date** | February 2026 |
|
| 190 |
+
| **Precision** | BF16 / FP16 |
|
| 191 |
+
| **Input Resolution** | 640px – 1536px (variant dependent) |
|
| 192 |
+
| **Max Sequence Length** | 2048 – 8192 tokens (variant dependent) |
|
| 193 |
+
| **Inference Engine** | vLLM (recommended) |
|
| 194 |
+
| **Framework** | PyTorch / Transformers |
|
| 195 |
|
| 196 |
+
---
|
| 197 |
+
|
| 198 |
+
## 🚀 Quick Start
|
| 199 |
+
|
| 200 |
+
Get running in under 5 minutes:
|
| 201 |
+
|
| 202 |
+
```python
|
| 203 |
+
from vllm import LLM, SamplingParams
|
| 204 |
+
from PIL import Image
|
| 205 |
+
|
| 206 |
+
# 1. Load model (Pro variant — default)
|
| 207 |
+
llm = LLM(
|
| 208 |
+
model="developerJenis/GT-REX-v4",
|
| 209 |
+
trust_remote_code=True,
|
| 210 |
+
max_model_len=4096,
|
| 211 |
+
gpu_memory_utilization=0.75,
|
| 212 |
+
max_num_seqs=128,
|
| 213 |
+
limit_mm_per_prompt={"image": 1},
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
+
# 2. Prepare input
|
| 217 |
+
image = Image.open("document.png")
|
| 218 |
+
prompt = "Extract all text from this document."
|
| 219 |
+
|
| 220 |
+
# 3. Run inference
|
| 221 |
+
sampling_params = SamplingParams(
|
| 222 |
+
temperature=0.0,
|
| 223 |
+
max_tokens=4096,
|
| 224 |
+
)
|
| 225 |
+
|
| 226 |
+
outputs = llm.generate(
|
| 227 |
+
[{
|
| 228 |
+
"prompt": prompt,
|
| 229 |
+
"multi_modal_data": {"image": image},
|
| 230 |
+
}],
|
| 231 |
+
sampling_params=sampling_params,
|
| 232 |
+
)
|
| 233 |
+
|
| 234 |
+
# 4. Get results
|
| 235 |
+
result = outputs[0].outputs[0].text
|
| 236 |
+
print(result)
|
| 237 |
+
```
|
| 238 |
+
|
| 239 |
+
---
|
| 240 |
|
| 241 |
## 💻 Installation
|
| 242 |
|
| 243 |
+
### Prerequisites
|
| 244 |
+
|
| 245 |
+
- Python 3.9+
|
| 246 |
+
- CUDA 11.8+ (GPU required)
|
| 247 |
+
- 8 GB+ VRAM (Pro variant), 4 GB+ (Nano), 12 GB+ (Ultra)
|
| 248 |
+
|
| 249 |
+
### Install Dependencies
|
| 250 |
+
|
| 251 |
```bash
|
| 252 |
pip install vllm pillow torch transformers
|
| 253 |
```
|
| 254 |
|
| 255 |
+
### Verify Installation
|
| 256 |
+
|
| 257 |
+
```python
|
| 258 |
+
from vllm import LLM
|
| 259 |
+
print("vLLM installed successfully!")
|
| 260 |
+
```
|
| 261 |
+
|
| 262 |
---
|
| 263 |
|
| 264 |
+
## 📖 Usage Examples
|
| 265 |
+
|
| 266 |
+
### Basic Text Extraction
|
| 267 |
+
|
| 268 |
+
```python
|
| 269 |
+
prompt = "Extract all text from this document image."
|
| 270 |
+
```
|
| 271 |
+
|
| 272 |
+
### Structured JSON Extraction
|
| 273 |
+
|
| 274 |
+
```python
|
| 275 |
+
prompt = """Extract the following fields from this invoice as JSON:
|
| 276 |
+
{
|
| 277 |
+
"invoice_number": "",
|
| 278 |
+
"date": "",
|
| 279 |
+
"vendor_name": "",
|
| 280 |
+
"total_amount": "",
|
| 281 |
+
"line_items": [
|
| 282 |
+
{"description": "", "quantity": "", "unit_price": "", "amount": ""}
|
| 283 |
+
]
|
| 284 |
+
}"""
|
| 285 |
+
```
|
| 286 |
+
|
| 287 |
+
### Table Extraction (Markdown Format)
|
| 288 |
+
|
| 289 |
+
```python
|
| 290 |
+
prompt = "Extract all tables from this document in Markdown table format."
|
| 291 |
+
```
|
| 292 |
+
|
| 293 |
+
### Key-Value Pair Extraction
|
| 294 |
+
|
| 295 |
+
```python
|
| 296 |
+
prompt = """Extract all key-value pairs from this form.
|
| 297 |
+
Return as:
|
| 298 |
+
Key: Value
|
| 299 |
+
Key: Value
|
| 300 |
+
..."""
|
| 301 |
+
```
|
| 302 |
+
|
| 303 |
+
### Handwritten Text Transcription
|
| 304 |
+
|
| 305 |
+
```python
|
| 306 |
+
prompt = "Transcribe all handwritten text from this image accurately."
|
| 307 |
+
```
|
| 308 |
+
|
| 309 |
+
### Multi-Document Batch Processing
|
| 310 |
+
|
| 311 |
+
```python
|
| 312 |
+
from PIL import Image
|
| 313 |
+
from vllm import LLM, SamplingParams
|
| 314 |
+
|
| 315 |
+
llm = LLM(
|
| 316 |
+
model="developerJenis/GT-REX-v4",
|
| 317 |
+
trust_remote_code=True,
|
| 318 |
+
max_model_len=4096,
|
| 319 |
+
gpu_memory_utilization=0.75,
|
| 320 |
+
max_num_seqs=128,
|
| 321 |
+
limit_mm_per_prompt={"image": 1},
|
| 322 |
+
)
|
| 323 |
+
|
| 324 |
+
# Prepare batch
|
| 325 |
+
image_paths = ["doc1.png", "doc2.png", "doc3.png"]
|
| 326 |
+
prompts = []
|
| 327 |
+
for path in image_paths:
|
| 328 |
+
img = Image.open(path)
|
| 329 |
+
prompts.append({
|
| 330 |
+
"prompt": "Extract all text from this document.",
|
| 331 |
+
"multi_modal_data": {"image": img},
|
| 332 |
+
})
|
| 333 |
+
|
| 334 |
+
# Run batch inference
|
| 335 |
+
sampling_params = SamplingParams(temperature=0.0, max_tokens=4096)
|
| 336 |
+
outputs = llm.generate(prompts, sampling_params=sampling_params)
|
| 337 |
+
|
| 338 |
+
# Collect results
|
| 339 |
+
for i, output in enumerate(outputs):
|
| 340 |
+
print(f"--- Document {i + 1} ---")
|
| 341 |
+
print(output.outputs[0].text)
|
| 342 |
+
print()
|
| 343 |
+
```
|
| 344 |
+
|
| 345 |
+
---
|
| 346 |
+
|
| 347 |
+
## 🏢 Use Cases
|
| 348 |
+
|
| 349 |
+
| Domain | Application | Recommended Variant |
|
| 350 |
+
|--------|-------------|---------------------|
|
| 351 |
+
| **Finance** | Invoice processing, receipt scanning, bank statements | Pro / Nano |
|
| 352 |
+
| **Legal** | Contract analysis, clause extraction, legal filings | Ultra |
|
| 353 |
+
| **Healthcare** | Medical records, prescriptions, lab reports | Ultra |
|
| 354 |
+
| **Government** | Form processing, ID verification, tax documents | Pro |
|
| 355 |
+
| **Insurance** | Claims processing, policy documents | Pro |
|
| 356 |
+
| **Education** | Exam paper digitization, handwritten notes | Pro / Ultra |
|
| 357 |
+
| **Logistics** | Shipping labels, waybills, packing lists | Nano |
|
| 358 |
+
| **Real Estate** | Property documents, deeds, mortgage papers | Pro |
|
| 359 |
+
| **Retail** | Product catalogs, price tags, inventory lists | Nano |
|
| 360 |
+
|
| 361 |
+
---
|
| 362 |
+
|
| 363 |
+
## 📈 Performance Benchmarks
|
| 364 |
+
|
| 365 |
+
### Throughput by Variant (NVIDIA A100 80GB)
|
| 366 |
+
|
| 367 |
+
| Variant | Single Image | Batch (32) | Batch (128) |
|
| 368 |
+
|---------|-------------|------------|-------------|
|
| 369 |
+
| Nano | ~1.2s | ~15s | ~55s |
|
| 370 |
+
| Pro | ~3.5s | ~45s | ~170s |
|
| 371 |
+
| Ultra | ~7.0s | ~110s | ~380s |
|
| 372 |
+
|
| 373 |
+
### Accuracy by Document Type (Pro Variant)
|
| 374 |
+
|
| 375 |
+
| Document Type | Character Accuracy | Field Accuracy |
|
| 376 |
+
|---------------|--------------------|----------------|
|
| 377 |
+
| Printed invoices | 98.5%+ | 96%+ |
|
| 378 |
+
| Typed contracts | 98%+ | 95%+ |
|
| 379 |
+
| Handwritten notes | 92%+ | 88%+ |
|
| 380 |
+
| Dense tables | 96%+ | 93%+ |
|
| 381 |
+
| Low-quality scans | 94%+ | 90%+ |
|
| 382 |
+
|
| 383 |
+
> **Note:** Benchmark numbers are approximate and may vary based on document quality, content complexity, and hardware configuration.
|
| 384 |
+
|
| 385 |
+
---
|
| 386 |
+
|
| 387 |
+
## 🧠 Prompt Engineering Guide
|
| 388 |
+
|
| 389 |
+
Get the best results from GT-REX-v4 with these prompt strategies:
|
| 390 |
+
|
| 391 |
+
### Do's
|
| 392 |
+
|
| 393 |
+
- **Be specific** about what to extract ("Extract the invoice number and total amount")
|
| 394 |
+
- **Specify output format** ("Return as JSON", "Return as Markdown table")
|
| 395 |
+
- **Provide schema** for structured extraction (show the expected JSON keys)
|
| 396 |
+
- **Use clear instructions** ("Transcribe exactly as written, preserving spelling errors")
|
| 397 |
+
|
| 398 |
+
### Don'ts
|
| 399 |
+
|
| 400 |
+
- Avoid vague prompts ("What is this?")
|
| 401 |
+
- Don't ask for analysis or summarization — GT-REX is optimized for **extraction**
|
| 402 |
+
- Don't include unrelated context in the prompt
|
| 403 |
+
|
| 404 |
+
### Example Prompts
|
| 405 |
+
|
| 406 |
+
```text
|
| 407 |
+
# Simple extraction
|
| 408 |
+
"Extract all text from this document."
|
| 409 |
+
|
| 410 |
+
# Targeted extraction
|
| 411 |
+
"Extract only the table on this page as a Markdown table."
|
| 412 |
+
|
| 413 |
+
# Schema-driven extraction
|
| 414 |
+
"Extract data matching this schema: {name: str, date: str, amount: float}"
|
| 415 |
+
|
| 416 |
+
# Preservation mode
|
| 417 |
+
"Transcribe this document exactly as written, preserving original formatting."
|
| 418 |
+
```
|
| 419 |
+
|
| 420 |
+
---
|
| 421 |
+
|
| 422 |
+
## 🔌 API Integration
|
| 423 |
+
|
| 424 |
+
### FastAPI Server Example
|
| 425 |
+
|
| 426 |
+
```python
|
| 427 |
+
from fastapi import FastAPI, UploadFile
|
| 428 |
+
from PIL import Image
|
| 429 |
+
from vllm import LLM, SamplingParams
|
| 430 |
+
import io
|
| 431 |
+
|
| 432 |
+
app = FastAPI()
|
| 433 |
+
|
| 434 |
+
llm = LLM(
|
| 435 |
+
model="developerJenis/GT-REX-v4",
|
| 436 |
+
trust_remote_code=True,
|
| 437 |
+
max_model_len=4096,
|
| 438 |
+
gpu_memory_utilization=0.75,
|
| 439 |
+
max_num_seqs=128,
|
| 440 |
+
limit_mm_per_prompt={"image": 1},
|
| 441 |
+
)
|
| 442 |
+
|
| 443 |
+
sampling_params = SamplingParams(temperature=0.0, max_tokens=4096)
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
@app.post("/extract")
|
| 447 |
+
async def extract_text(file: UploadFile, prompt: str = "Extract all text."):
|
| 448 |
+
image_bytes = await file.read()
|
| 449 |
+
image = Image.open(io.BytesIO(image_bytes)).convert("RGB")
|
| 450 |
+
|
| 451 |
+
outputs = llm.generate(
|
| 452 |
+
[{
|
| 453 |
+
"prompt": prompt,
|
| 454 |
+
"multi_modal_data": {"image": image},
|
| 455 |
+
}],
|
| 456 |
+
sampling_params=sampling_params,
|
| 457 |
+
)
|
| 458 |
+
|
| 459 |
+
return {"text": outputs[0].outputs[0].text}
|
| 460 |
+
```
|
| 461 |
+
|
| 462 |
+
---
|
| 463 |
+
|
| 464 |
+
## 🛠️ Troubleshooting
|
| 465 |
+
|
| 466 |
+
| Issue | Solution |
|
| 467 |
+
|-------|----------|
|
| 468 |
+
| **CUDA Out of Memory** | Reduce `gpu_memory_utilization` or switch to Nano variant |
|
| 469 |
+
| **Slow inference** | Increase `max_num_seqs` for better batching; use Nano for speed |
|
| 470 |
+
| **Truncated output** | Increase `max_tokens` in `SamplingParams` |
|
| 471 |
+
| **Low accuracy on small text** | Switch to Ultra variant for higher resolution |
|
| 472 |
+
| **Garbled multilingual text** | Ensure image resolution is sufficient; try Ultra variant |
|
| 473 |
+
|
| 474 |
+
---
|
| 475 |
+
|
| 476 |
+
## 🔧 Hardware Recommendations
|
| 477 |
+
|
| 478 |
+
| Variant | Minimum GPU | Recommended GPU |
|
| 479 |
+
|---------|-------------|-----------------|
|
| 480 |
+
| Nano | NVIDIA T4 (16 GB) | NVIDIA A10 (24 GB) |
|
| 481 |
+
| Pro | NVIDIA A10 (24 GB) | NVIDIA A100 (40 GB) |
|
| 482 |
+
| Ultra | NVIDIA A100 (40 GB) | NVIDIA A100 (80 GB) |
|
| 483 |
+
|
| 484 |
+
---
|
| 485 |
+
|
| 486 |
+
## 📜 License
|
| 487 |
+
|
| 488 |
+
This model is released under the **MIT License**. You are free to use, modify, and distribute it for both commercial and non-commercial purposes.
|
| 489 |
+
|
| 490 |
+
---
|
| 491 |
+
|
| 492 |
+
## 📖 Citation
|
| 493 |
+
|
| 494 |
+
If you use GT-REX-v4 in your work, please cite:
|
| 495 |
+
|
| 496 |
+
```bibtex
|
| 497 |
+
@misc{gtrex-v4-2026,
|
| 498 |
+
title = {GT-REX-v4: Production-Grade OCR with Vision-Language Models},
|
| 499 |
+
author = {Hathaliya, Jenis},
|
| 500 |
+
year = {2026},
|
| 501 |
+
month = {February},
|
| 502 |
+
url = {https://huggingface.co/developerJenis/GT-REX-v4},
|
| 503 |
+
note = {GothiTech Recognition \& Extraction eXpert, Version 4}
|
| 504 |
+
}
|
| 505 |
+
```
|
| 506 |
+
|
| 507 |
+
---
|
| 508 |
+
|
| 509 |
+
## 🤝 Contact & Support
|
| 510 |
+
|
| 511 |
+
- **Developer:** Jenis Hathaliya
|
| 512 |
+
- **Organization:** GothiTech
|
| 513 |
+
- **HuggingFace:** [developerJenis](https://huggingface.co/developerJenis)
|
| 514 |
+
|
| 515 |
+
---
|
| 516 |
+
|
| 517 |
+
<p align="center">
|
| 518 |
+
Built with ❤️ by <strong>GothiTech</strong>
|
| 519 |
+
</p>
|
| 520 |
+
|
| 521 |
+
<p align="center">
|
| 522 |
+
<em>Last updated: February 2026</em><br>
|
| 523 |
+
<em>Model Version: v4.0 | Variants: Nano | Pro | Ultra</em>
|
| 524 |
+
</p>
|