Run this model with HF Jobs

Run OpenTensorLab/Qwen3.5-9B-Signature-W4A16 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/OpenTensorLab/Qwen3.5-9B-Signature-W4A16. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/OpenTensorLab/Qwen3.5-9B-Signature-W4A16 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/OpenTensorLab/Qwen3.5-9B-Signature-W4A16. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
File size: 13,359 Bytes
7b2dad0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
---

license: apache-2.0
library_name: transformers
pipeline_tag: image-text-to-text
base_model:
  - Qwen/Qwen3.5-9B
datasets:
  - OpenTensorLab/signature-detection-sft
tags:
  - signature-detection
  - visual-grounding
  - document-ai
  - vqa
  - structured-outputs
  - pydantic
  - unsloth
  - qwen3.5
  - vllm
---


# Qwen3.5 Signature Detection & Visual Grounding Suite

Fine-tuned **Qwen3.5** vision-language models (**9B** and **4B**) specialized in document signature verification, signer role attribution, counting, and normalized `[0, 1000]` bounding-box localization. 

Trained using **Unsloth** on [`OpenTensorLab/signature-detection-sft`](https://huggingface.co/datasets/OpenTensorLab/signature-detection-sft), this model family outputs deterministic, Pydantic-validated JSON across single-role queries, hard-negative checks, full-page open discovery, and document VQA.

> **Recommended Checkpoint:** **`OpenTensorLab/Qwen3.5-9B-Signature`** (and its **`W4A16`** quantized release) delivers the strongest spatial precision, role disambiguation, and hard-negative rejection performance across complex multi-signer forms and vouchers.

---

## Model Family & Available Artifacts

All checkpoints are grouped in the [Qwen3.5 Signature Detection & Visual Grounding Collection](https://huggingface.co/collections/OpenTensorLab/signature-detection):

| Repository | Base Model | Format / Precision | Recommended Use Case |
| :--- | :--- | :--- | :--- |
| **[`OpenTensorLab/Qwen3.5-9B-Signature`](https://huggingface.co/OpenTensorLab/Qwen3.5-9B-Signature)** | `Qwen/Qwen3.5-9B` | Merged `BF16` | Best overall accuracy, fine-grained bounding boxes, and downstream quantization |
| **[`OpenTensorLab/Qwen3.5-9B-Signature-W4A16`](https://huggingface.co/OpenTensorLab/Qwen3.5-9B-Signature-W4A16)** | `Qwen/Qwen3.5-9B` | `W4A16` Quantized | High-throughput production serving on single-GPU setups via `vLLM` |
| **[`OpenTensorLab/Qwen3.5-9B-Signature-Adapter`](https://huggingface.co/OpenTensorLab/Qwen3.5-9B-Signature-Adapter)** | `Qwen/Qwen3.5-9B` | LoRA Adapter (`r=16, alpha=16`) | Lightweight adapter loading or multi-LoRA serving |
| **[`OpenTensorLab/Qwen3.5-4B-Signature`](https://huggingface.co/OpenTensorLab/Qwen3.5-4B-Signature)** | `Qwen/Qwen3.5-4B` | Merged `BF16` | Low-latency / constrained-VRAM document extraction |
| **[`OpenTensorLab/Qwen3.5-4B-Signature-Adapter`](https://huggingface.co/OpenTensorLab/Qwen3.5-4B-Signature-Adapter)** | `Qwen/Qwen3.5-4B` | LoRA Adapter (`r=16, alpha=32`) | Lightweight 4B adapter deployment |

---

## Capabilities & Supported Tasks

The models are trained across four complementary document-understanding tasks:

1. **Positive Grounding (`positive_grounding`):** Verifies whether a specific role (e.g., *Director*, *Secretary*, *Applicant*, *Authorized Signatory*) has signed the document and returns exact `[x1, y1, x2, y2]` coordinates.

2. **Hard-Negative Rejection (`hard_negative_grounding`):** Accurately returns `"is_present": false` and `"signatures": []` when queried for plausible roles that are absent from the page, suppressing false-positive hallucinations.

3. **Open Discovery (`open_discovery`):** Scans the entire page (`"Identify and locate all signatures present on this document."`) and extracts every signature alongside its associated role label and bounding box.
4. **Document VQA (`pure_vqa`):** Answers signature count and signer-role inventory questions in the unified JSON schema.



---



## Output JSON Schema



Every response strictly conforms to the following Pydantic schema:



```json

{

  "answer": "Yes, the Director signature is present on this document.",

  "is_present": true,

  "count": 2,

  "signatures": [

    {

      "role": "Director",

      "bbox_2d": [730, 309, 914, 377]

    },

    {

      "role": "Director",

      "bbox_2d": [788, 809, 942, 882]

    }

  ]

}



```



* **`answer`** (`str`): Natural-language summary answering the prompt.
* **`is_present`** (`bool`): `true` if at least one matching signature is detected; `false` otherwise.

* **`count`** (`int`): Total number of items in `signatures`.

* **`signatures`** (`list[dict]`):

* **`role`** (`str`): Signer role, title, or label associated with the signature.

* **`bbox_2d`** (`list[int]`): `[xmin, ymin, xmax, ymax]` normalized to **`[0, 1000]`** relative to the upright image width and height.



---

## Serving & Inference

### 1. High-Throughput Serving with vLLM

#### Option A: Serving Merged or Quantized Checkpoints (Recommended)

```bash

vllm serve OpenTensorLab/Qwen3.5-9B-Signature-W4A16 \

  --host 0.0.0.0 \

  --port 8000 \

  --trust-remote-code \

  --max-model-len 16384 \

  --enable-prefix-caching \

  --default-chat-template-kwargs '{"enable_thinking": false}'



```

#### Option B: Serving the LoRA Adapter on Top of the Base Model

```bash

vllm serve OpenTensorLab/Qwen3.5-9B-W4A16-AutoRound-GPTQ \

  --host 0.0.0.0 \

  --port 8000 \

  --enable-lora \

  --lora-modules signature-adapter=OpenTensorLab/Qwen3.5-9B-Signature-Adapter \

  --max-lora-rank 16 \

  --max-loras 1 \

  --trust-remote-code \

  --max-model-len 16384 \

  --enable-prefix-caching \

  --default-chat-template-kwargs '{"enable_thinking": false}'

```

> **Note:** When serving with `--lora-modules`, pass (the registered adapter name) in your OpenAI SDK requests instead of the base model ID. For the 4B adapter, swap the base model and path to `Qwen/Qwen3.5-4B` and `OpenTensorLab/Qwen3.5-4B-Signature-Adapter`.

### 2. Structured Extraction with OpenAI SDK & Pydantic

> **Important:** Ensure input images are EXIF-transposed and rotated upright (`0°`) before inference, as all training coordinates are normalized to upright page orientations.

```python

import base64

from io import BytesIO

from openai import OpenAI

from PIL import Image, ImageOps

from pydantic import BaseModel, ConfigDict





class SignatureItem(BaseModel):

    model_config = ConfigDict(extra="forbid")

    role: str

    bbox_2d: list[int]





class SignatureResponse(BaseModel):

    model_config = ConfigDict(extra="forbid")

    answer: str

    is_present: bool

    count: int

    signatures: list[SignatureItem]





def encode_upright_image(image_path: str) -> tuple[str, int, int]:

    img = ImageOps.exif_transpose(Image.open(image_path)).convert("RGB")

    width, height = img.size

    buf = BytesIO()

    img.save(buf, format="JPEG", quality=95)

    b64 = base64.b64encode(buf.getvalue()).decode("utf-8")

    return b64, width, height





client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")

b64_img, width, height = encode_upright_image("document.jpg")



completion = client.chat.completions.parse(

    model="OpenTensorLab/Qwen3.5-9B-Signature-W4A16",

    temperature=0.0,

    messages=[

        {

            "role": "user",

            "content": [

                {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{b64_img}"}},

                {"type": "text", "text": "Identify and locate all signatures present on this document."},

            ],

        }

    ],

    response_format=SignatureResponse,

)



result: SignatureResponse = completion.choices[0].message.parsed

print(result.model_dump_json(indent=2))



# Convert normalized [0, 1000] coordinates back to pixel coordinates

for sig in result.signatures:

    x1, y1, x2, y2 = sig.bbox_2d

    pixel_box = [

        int(x1 / 1000 * width),

        int(y1 / 1000 * height),

        int(x2 / 1000 * width),

        int(y2 / 1000 * height),

    ]

    print(f"Role: {sig.role} | Pixel Box: {pixel_box}")



```

---

## Training Details

Both model variants were fine-tuned with **Unsloth** (`gradient_checkpointing: unsloth`, `train_on_completions: true`) on `OpenTensorLab/signature-detection-sft` (12,000 training examples / 2,530 validation examples across orientation-corrected document scans), updating both vision and language layers (`q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj`):

| Hyperparameter | Qwen3.5-9B Configuration | Qwen3.5-4B Configuration |
| --- | --- | --- |
| **Max Sequence Length** | `8192` | `8192` |
| **Epochs** | `1` | `1` |
| **Effective Batch Size** | `16` (`batch_size=4`, `grad_accum=4`) | `16` (`batch_size=2`, `grad_accum=8`) |
| **Learning Rate** | `5e-5` (Cosine, `40` warmup steps) | `1e-4` (Cosine, `40` warmup steps) |
| **Optimizer & Weight Decay** | `adamw_8bit`, `0.05` | `adamw_8bit`, `0.02` |
| **LoRA Rank / Alpha** | `r=16`, `alpha=16` (`use_rslora=true`) | `r=16`, `alpha=32` (`use_rslora=true`) |
| **LoRA Dropout** | `0.1` | `0.05` |
| **Fine-Tuned Modules** | Vision + Language (Attention & MLP) | Vision + Language (Attention & MLP) |

---
### 🚀 Deploy on RunPod

One-click launch environments pre-configured with PyTorch, CUDA, and dependencies for fine-tuning or quantization.

> 🎁 **Need GPU compute?** Sign up via [RunPod](https://runpod.io?ref=iabrlp7z) and get **$5–$500 in free credits** when you add your first $10.

#### PyTorch 2.15

| Template | CUDA Version | Docker Image | Template ID | Deploy |
| :--- | :--- | :--- | :--- | :--- |
| **PyTorch 2.15 (CUDA 13.2)** | 13.2 | `vishva123/cuda-13.2-pytorch-2.15-runpod` | `0rsw686010` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=0rsw686010&ref=iabrlp7z) |
| **PyTorch 2.15 (CUDA 13.4)** | 13.4 | `vishva123/cuda-13.4-pytorch-2.15-runpod` | `0s0rhdfaqy` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=0s0rhdfaqy&ref=iabrlp7z) |

#### PyTorch 2.14

| Template | CUDA Version | Docker Image | Template ID | Deploy |
| :--- | :--- | :--- | :--- | :--- |
| **PyTorch 2.14 (CUDA 12.6)** | 12.6 | `vishva123/cuda-12.6-pytorch-2.14-runpod` | `d7lxsa4w9m` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=d7lxsa4w9m&ref=iabrlp7z) |
| **PyTorch 2.14 (CUDA 13.0)** | 13.0 | `vishva123/cuda-13.0-pytorch-2.14-runpod` | `yk0y6j6rpg` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=yk0y6j6rpg&ref=iabrlp7z) |
| **PyTorch 2.14 (CUDA 13.2)** | 13.2 | `vishva123/cuda-13.2-pytorch-2.14-runpod` | `gsp4gwx0nw` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=gsp4gwx0nw&ref=iabrlp7z) |


#### PyTorch 2.13

| Template | CUDA Version | Docker Image | Template ID | Deploy |
| :--- | :--- | :--- | :--- | :--- |
| **PyTorch 2.13 (CUDA 12.6)** | 12.6 | `vishva123/cuda-12.6-pytorch-2.13-runpod` | `gmlupxnxfk` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=gmlupxnxfk&ref=iabrlp7z) |
| **PyTorch 2.13 (CUDA 13.0)** | 13.0 | `vishva123/cuda-13.0-pytorch-2.13-runpod` | `y3j8xvk4f4` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=y3j8xvk4f4&ref=iabrlp7z) |
| **PyTorch 2.13 (CUDA 13.2)** | 13.2 | `vishva123/cuda-13.2-pytorch-2.13-runpod` | `vigpissn5w` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=vigpissn5w&ref=iabrlp7z) |

#### PyTorch 2.12

| Template | CUDA Version | Docker Image | Template ID | Deploy |
| :--- | :--- | :--- | :--- | :--- |
| **PyTorch 2.12 (CUDA 12.6)** | 12.6 | `vishva123/cuda-12.6-pytorch-2.12-runpod` | `ctmz86zmf0` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=ctmz86zmf0&ref=iabrlp7z) |
| **PyTorch 2.12 (CUDA 13.0)** | 13.0 | `vishva123/cuda-13.0-pytorch-2.12-runpod` | `qjko5yiwzi` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=qjko5yiwzi&ref=iabrlp7z) |
| **PyTorch 2.12 (CUDA 13.2)** | 13.2 | `vishva123/cuda-13.2-pytorch-2.12-runpod` | `ifg6xmye0f` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=ifg6xmye0f&ref=iabrlp7z) |

---

## Limitations & Recommendations

* **Page Orientation:** Bounding boxes are trained exclusively on upright (`0°`) images. For rotated or scanned PDFs, run an orientation classifier (e.g., PaddleOCR `PP-LCNet_x1_0_doc_ori`) prior to inference.
* **Role Label Supervision:** Signer role annotations in the underlying training split were generated via VLM teacher distillation and may occasionally normalize rare institutional titles to standard role names.
* **Model Selection:** Use **`Qwen3.5-9B-Signature`** (or **`Qwen3.5-9B-Signature-W4A16`**) for production banking/legal documents; use the **`4B`** variant only when strict edge-memory or latency budgets apply.